2

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.

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
user33061
  • 1,747
  • 6
  • 26
  • 29

6 Answers6

6

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++.

Community
  • 1
  • 1
Michael Burr
  • 333,147
  • 50
  • 533
  • 760
4

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++.

Community
  • 1
  • 1
Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
  • 4
    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 Dec 02 '08 at 17:44
  • 1
    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 Dec 02 '08 at 18:22
  • "Some" C++ compilers lack C99 features (but who needs them in *2009*؟) – jfs Feb 24 '09 at 11:58
2

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

Walter Bright
  • 4,277
  • 1
  • 23
  • 28
1

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
  • 172
  • 1
  • 10
0

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
  • 56,304
  • 9
  • 91
  • 158
0

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
  • 3,104
  • 3
  • 23
  • 30