How to compile c code with vc++?

Z

Zootal

I have some c code that I would like to compile with visual studio, and
retain c compatibility. IOW, converting it to c++ is not an option. Is there
a way to configure the project to be compatible with c code? I can compile
the code just fine with gcc, so I believe the code is ok, but I get numerous
errors with visual studio. I'm using Visual Studio 2005
 
D

Doug Harrison [MVP]

I have some c code that I would like to compile with visual studio, and
retain c compatibility. IOW, converting it to c++ is not an option. Is there
a way to configure the project to be compatible with c code? I can compile
the code just fine with gcc, so I believe the code is ok, but I get numerous
errors with visual studio. I'm using Visual Studio 2005

By default, files that end with the extension .c are compiled as C. You can
also force the issue with the /Tc and /TC compiler options (and vice versa
with /Tp and /TP).
 
Z

Zootal

Doug Harrison said:
By default, files that end with the extension .c are compiled as C. You
can
also force the issue with the /Tc and /TC compiler options (and vice versa
with /Tp and /TP).

Thanks - I didn't know that. I'm finding there are issues with some of the
syntax, enough that I'm not sure it's worth the trouble to get it to work
with Visual Studio. It works with gcc, but I'm not sure if gcc has some
non-ansi c extensions that VS doesn't have <sigh>.
 
D

David Wilkinson

Zootal said:
Thanks - I didn't know that. I'm finding there are issues with some of the
syntax, enough that I'm not sure it's worth the trouble to get it to work
with Visual Studio. It works with gcc, but I'm not sure if gcc has some
non-ansi c extensions that VS doesn't have <sigh>.

Zootal:

The problem with some C code is that it is C99, which VC does not support (and
last time I heard is not going to support).

For C++, in recent years I have found excellent compatibility between VC and
gcc, and it is very easy to produce code that will compile under either.
 
Z

Zootal

David Wilkinson said:
Zootal:

The problem with some C code is that it is C99, which VC does not support
(and last time I heard is not going to support).

For C++, in recent years I have found excellent compatibility between VC
and gcc, and it is very easy to produce code that will compile under
either.

Ahh...it's GNU C, and VS definitely is not 100% compatible. It's code that
emulates parts of the linux kernel, and some of the libraries it links in is
actual kernel code - that is the actual problem, not the code I'm working
with. <sigh>....debugging with gcc is a pain....
 
B

Ben Voigt [C++ MVP]

Zootal said:
Ahh...it's GNU C, and VS definitely is not 100% compatible. It's code
that emulates parts of the linux kernel, and some of the libraries it
links in is actual kernel code - that is the actual problem, not the
code I'm working with. <sigh>....debugging with gcc is a pain....

There is gcc for windows. I don't think it generates debug information in
the Windows format though, so you may not get what you want. Googling, I
see some suggestions that windbg supports the COFF format still but VS
dropped support at version 7, so you can probably get source level debugging
using windbg.
 

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

Top