tags:

views:

320

answers:

6

I'm not sure, will the visual c ++ compiler express edition work for compiling c and if not can someone link me to an easy c compiler to use. Thanks in advance.

+3  A: 

Yes, it will work. C is a subset of C++ (for all but a very small number of exceptional cases). Any C++ compiler should work with valid C code.

See the answers to this question for some of the rare examples of C code that isn't valid C++.

Bill the Lizard
I wouldn't call it a subset. Those small number of exceptional cases are more than you might think. In any case it just so happens that VC++ is *also* a C compiler. Just save the file with the .c extension, and it will by default to C code. Alternatively you can pick the language in project settings
jalf
In a strict mathematical sense, no, C isn't a proper subset of C++. However, well-written C tends to be valid C++.
Bill the Lizard
"Some" C++ compilers lack C99 features (but who needs them in *2009*؟)
J.F. Sebastian
+5  A: 

To add to Bill The Lizard's answer - any C++ compiler will compile a file using C language rules if the file has a .c extension. This can be overriden to force a file to be compiled as C or C++ using command line options.

This is done with MSVC using the /Tc or /TC options to compile as C, and the /Tp or /TP options to compile as C++.

Michael Burr
"any C++ compiler" may be effectively true, but it's not required to be true by any standard.
Darron
@Darron - understood, but this is not really a standards question, it's a tools question.
Michael Burr
+1  A: 

http://www.bloodshed.net/compilers/index.html

maybe there's something to your liking there.

also there's always gcc: http://gcc.gnu.org/

Ariel Arjona
A: 

Depends partly on what C you're talking about. Visual C++ will happily compile C programs (make sure they've got a .c extension, and make sure the "Compile As" option in the "Advanced" part of the "C/C++" property pages is not set to C++ only), but is missing a whole lot of stuff in the C99 standard. If you're interested in the original standard C, Visual C++ will work very nicely.

David Thornley
A: 

Just small clarification - Visual C++ is not a compiler rather an IDE. The compiler will be cl.exe and as many sad there is no problem to compile C code with cl.
But there is other options like Windows ports of gcc or Watcom compiler

Ilya
+2  A: 

You can download a free copy of the Digital Mars C compiler.

Walter Bright