Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can i use c++ compiler to compile c source code? [duplicate]

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??

like image 255
caramel1995 Avatar asked Nov 29 '22 10:11

caramel1995


2 Answers

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

like image 32
littleadv Avatar answered Dec 06 '22 20:12

littleadv


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

like image 176
Yann Ramin Avatar answered Dec 06 '22 19:12

Yann Ramin