Possible Duplicate:
What issues can I expect compiling C code with a C++ compiler?
Just curious whether I could make use of a c++ compiler to compile c source code??Anyway is there any compiler that fully support c99 standard yet??
Possible Duplicate:
What issues can I expect compiling C code with a C++ compiler?
Just curious whether I could make use of a c++ compiler to compile c source code??Anyway is there any compiler that fully support c99 standard yet??
C++ is not a superset of C. There are places where they differ, which means some C code will not compile in C++ mode.
As for C99 support, GCC and Clang are the closest. Microsoft does not support C99, and only focuses on C++ (which overlaps with C99 in places).
You might have a problem compiling C code with a C++ compiler unless you explicitly restrict the compiler to use C (which all the C++ compilers know how to do). If the compiler uses C++ to compile C code you might have issues if in the C code you use words that are reserved in C++.
For example, C code like this:
int main(void) { int class = 5; return class;}
Will compile fine with a C compiler (or C++ compiler in C mode), but will not compile with a C++ compiler.
The two problems that I can quickly think of (there's probably more) that would arise when compiling C code with C++ is casting and variable names. For example:
char* new = malloc(20);
The above is valid C, but when compiling in C++ you would get the following errors:
char*
cannot be assigned to void*
without an explicit cast.new
is a keyword.Yes, some compilers do support C99. GCC probably does, but I only have experience using MSVC and they don't support it.