Which C tool?

J

john.bradshaw

Hi

I have a copy of Visual Studio 2005 and Borland Delphi but I'm at a
loss to find where I can start to code C applications, they all give me
options to work in C++ but as I am dealing with embedded systems and
PIC devices I can't use it.

Does anyone know if I can get Visual Studio, I think its better than
Borland, to work with C or failing that what is the best C programing
tool?

Thanks,

JB
 
R

Rafael Almeida

On 31 Oct 2006 17:17:07 -0800
Hi

I have a copy of Visual Studio 2005 and Borland Delphi but I'm at a
loss to find where I can start to code C applications, they all give
me options to work in C++ but as I am dealing with embedded systems
and PIC devices I can't use it.

Does anyone know if I can get Visual Studio, I think its better than
Borland, to work with C or failing that what is the best C programing
tool?

I suggest programming with vim. Other people may prefer emacs. They are
both great editors and they should suit your needs.
 
A

Adam Shea

On 31 Oct 2006 17:17:07 -0800


I suggest programming with vim. Other people may prefer emacs. They
are both great editors and they should suit your needs.

It sounds like you're working in Windows. I'd suggest either GVim for
an editor or DevC++ if you're looking for an IDE.

==
Adam Shea
 
M

Michael

I have a copy of Visual Studio 2005 and Borland Delphi but I'm at a
loss to find where I can start to code C applications, they all give me
options to work in C++ but as I am dealing with embedded systems and
PIC devices I can't use it.

Does anyone know if I can get Visual Studio, I think its better than
Borland, to work with C or failing that what is the best C programing
tool?

You may need something specific to your device or PIC. E.g. MicroChip
has their own C compiler for their PIC line, and there are third party
compilers specific to certain devices as well.

Depending on what you're doing, you may be able to use Visual Studio -
files that end in .c (not .cc or .cpp) are by default compiled as C
code, or you can set file-by-file or project-by-project settings to
compile as C instead of as C++ (under C/C++ Advanced). To write stuff
for an embedded device, you may need to download extensions that
support WinCE, which can be found by googling.

Michael
 
J

Jack Klein

You may need something specific to your device or PIC. E.g. MicroChip
has their own C compiler for their PIC line, and there are third party
compilers specific to certain devices as well.

Depending on what you're doing, you may be able to use Visual Studio -
files that end in .c (not .cc or .cpp) are by default compiled as C
code, or you can set file-by-file or project-by-project settings to
compile as C instead of as C++ (under C/C++ Advanced). To write stuff
for an embedded device, you may need to download extensions that
support WinCE, which can be found by googling.

Michael

I am wiping tears from my eyes from laughing so hard, but I just had
to respond even though it's way off-topic...

The notion of the incredible resource hogging, bloated POS WinCE
running on a PIC!

Pull the other one.
 
D

doug turnbull

Hi

I have a copy of Visual Studio 2005 and Borland Delphi but I'm at a
loss to find where I can start to code C applications, they all give me
options to work in C++ but as I am dealing with embedded systems and
PIC devices I can't use it.

Does anyone know if I can get Visual Studio, I think its better than
Borland, to work with C or failing that what is the best C programing
tool?

Thanks,

JB

I've been around the block a few times on editors and keep coming back
to Jen's File Editor
http://home.arcor.de/jensaltmann/JFE/jfe_eng.htm

Its buggy and kind of annoing at times. However I find it perfect for
big C projects with fairly flat directory structures. Beware, it loads
all text files into RAM, but this makes searching through files fast.
It also has a look/feel like Visual Studio.

Editplus is not bad either (google editplus). However its not freeware.

I'd honestly keep playing around with different editors until you found
one to your liking.
 
J

john.bradshaw

Thanks for the help, I'll have a look at the tools you mentioned. I
use tiny bootloader to work with pic 18f/16f devices and I suppose I
could write in notepad for all its worth but I've always been more
comfortable with IDEs.

Thanks,

JB
 
R

Roland Pibinger

I have a copy of Visual Studio 2005 and Borland Delphi but I'm at a
loss to find where I can start to code C applications, they all give me
options to work in C++ but as I am dealing with embedded systems and
PIC devices I can't use it.

You can, of course, write programs in C with Visual Studio 2005. The
Windows API is written in C.
Does anyone know if I can get Visual Studio, I think its better than
Borland, to work with C or failing that what is the best C programing
tool?

- Create a console project
- Remove all generated files like "stdafx.h"
- Add your files with *.c extension

I've just compiled the following program in Visual Studio 2005 (note
it's C: no prototypes, no cast for malloc)

int main() {
char* c = malloc (100);
strcpy (c, "Hello, world!");
printf ("%s", c);
free (c);
}

//Compiler output: C_Test - 0 error(s), 5 warning(s)

If you just want an editor (not an IDE) on Windows take a look at the
great freeware PSPad: http://www.pspad.com/en/

Best wishes,
Roland Pibinger
 
J

John Bode

Jack said:
I am wiping tears from my eyes from laughing so hard, but I just had
to respond even though it's way off-topic...

The notion of the incredible resource hogging, bloated POS WinCE
running on a PIC!

Pull the other one.

No one ever said it had to run *well*.
 
S

Simon Biber

Roland said:
I've just compiled the following program in Visual Studio 2005 (note
it's C: no prototypes, no cast for malloc)

Prototypes are encouraged for C code. You really should use int
<stdlib.h> and <string.h> to said:
int main() {
char* c = malloc (100);
strcpy (c, "Hello, world!");
printf ("%s", c);
free (c);
}

//Compiler output: C_Test - 0 error(s), 5 warning(s)

Here are the 5 diagnostics your code produces:

'malloc' undefined; assuming extern returning int
'initializing' : 'char *' differs in levels of indirection from 'int'
'strcpy' undefined; assuming extern returning int
'printf' undefined; assuming extern returning int
'free' undefined; assuming extern returning int

These are _real_ problems. They may not prevent the code from working on
your 32-bit system, but just wait until someone tries to run it on a
64-bit system where ints and pointers have a different size.

They can all be fixed by including the required header files.
 
B

Barry Schwarz

Hi

I have a copy of Visual Studio 2005 and Borland Delphi but I'm at a
loss to find where I can start to code C applications, they all give me
options to work in C++ but as I am dealing with embedded systems and
PIC devices I can't use it.

Does anyone know if I can get Visual Studio, I think its better than
Borland, to work with C or failing that what is the best C programing
tool?
This group deals with the language as defined by the standard, not
with the compilers that process the code. Try the microsoft.public.vc
hierarchy for questions about using VS for C.


Remove del for email
 
R

Roland Pibinger

Here are the 5 diagnostics your code produces:

'malloc' undefined; assuming extern returning int
'initializing' : 'char *' differs in levels of indirection from 'int'
'strcpy' undefined; assuming extern returning int
'printf' undefined; assuming extern returning int
'free' undefined; assuming extern returning int

These are _real_ problems. They may not prevent the code from working on
your 32-bit system, but just wait until someone tries to run it on a
64-bit system where ints and pointers have a different size.
They can all be fixed by including the required header files.

That's understood. I just wanted to be sure that VS 2005 compiled the
program as C program, not as C++ program. Therefore I needed program
that was valid in C but not in C++.

Best regards,
Roland Pibinger
 
K

Kenneth Brody

Hi

I have a copy of Visual Studio 2005 and Borland Delphi but I'm at a
loss to find where I can start to code C applications, they all give me
options to work in C++ but as I am dealing with embedded systems and
PIC devices I can't use it.

Does anyone know if I can get Visual Studio, I think its better than
Borland, to work with C or failing that what is the best C programing
tool?

Well, ignoring the "what is the best" part of the question...

VS2005 should handle C programs just fine. (Unless Microsoft really
screwed everyone over by removing that possibility.) Just don't use
any of the "wizards", and start with an "empty project". Then add
your C source (with ".c" extensions) to the project. At least this
is how earlier versions of Visual Studio did it.

If this doesn't work, or you need further help, you'll need to ask in
one of the Microsoft- or Windows-specific newsgroups.

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:[email protected]>
 
F

Flash Gordon

Roland said:
That's understood. I just wanted to be sure that VS 2005 compiled the
program as C program, not as C++ program. Therefore I needed program
that was valid in C but not in C++.

Based on those warnings I don't think the program is valid C either. The
C standard explicitly allows compilers to compile invalid programs even
where it requires that the compiler produce some kind of diagnostic
message, where a diagnostic message could be as unhelpful as, "I think
you stink."

If you wand a program that is valid C but invalid C++ here are a few
simple examples

int main(void)
{
int new;
return 0;
}

int main(void)
{
int i;
void *p = &i;
return 0;
}

int main(void)
{
int class;
return 0;
}

You may get warnings about unused variables, but all of the above are
strictly conforming C programs but any C++ compiler is required to
produce a diagnostic for every one of them. Of course, if the C++
standard is anything like the C standard the compiler could just
generate a warning but compile the code anyway.
 
G

Guest

Flash said:
If you wand a program that is valid C but invalid C++ here are a few
simple examples [...]
int main(void)
{
int i;
void *p = &i;
return 0;
}

This is both valid C and valid C++. The conversions in the opposite
direction are the ones that are disallowed in C++.
 
K

Keith Thompson

Flash Gordon said:
If you wand a program that is valid C but invalid C++ here are a few
simple examples

int main(void)
{
int new;
return 0;
}
[snip]

Or if you want the program to tell you at run time:

#include <stdio.h>
int main(void)
{
if (sizeof(int) == 1) {
printf("Can't tell\n");
}
else if (sizeof 'x' == sizeof(int)) {
printf("This is C\n");
}
else if (sizeof 'x' == 1) {
printf("This is C++\n");
}
else {
printf("Compiler bug?\n");
}
return 0;
}
 
F

Flash Gordon

Harald said:
Flash said:
If you wand a program that is valid C but invalid C++ here are a few
simple examples [...]
int main(void)
{
int i;
void *p = &i;
return 0;
}

This is both valid C and valid C++. The conversions in the opposite
direction are the ones that are disallowed in C++.

Well, 2 out of 3 ain't bad.
 
C

CBFalconer

Roland said:
.... snip ...

That's understood. I just wanted to be sure that VS 2005 compiled
the program as C program, not as C++ program. Therefore I needed
program that was valid in C but not in C++.

#include <stdio.h>
int main(void) {
char class[24];
const char *new = "I am a C compiler";

strcpy(class, new);
puts(new);
return 0;
}
 
J

jaysome

Roland said:
... snip ...

That's understood. I just wanted to be sure that VS 2005 compiled
the program as C program, not as C++ program. Therefore I needed
program that was valid in C but not in C++.

#include <stdio.h>
int main(void) {
char class[24];
const char *new = "I am a C compiler";

strcpy(class, new);
puts(new);
return 0;
}

warning C4013: 'strcpy' undefined; assuming extern returning int

I think you need to include <string.h>. In VS 2005, or VS 6 for that
matter, just double-click on "strcpy" and press F1 to get the best
help on the planet. Thanks Microsoft.
 
R

Richard Heathfield

jaysome said:

warning C4013: 'strcpy' undefined; assuming extern returning int

I think you need to include <string.h>.
Correct.

In VS 2005, or VS 6 for that
matter, just double-click on "strcpy" and press F1 to get the best
help on the planet.

<cough> No comment.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,158
Latest member
Vinay_Kumar Nevatia
Top