c++cgccg++

is there any circumstance under which valid C code will not compile properly using g++


Possible Duplicate:
“C subset of C++” -> Where not ? examples?

I am aware that C is a subset of C++ (i.e. there does not exist valid C code that is not valid C++ code). My question is whether g++ is completely compatible with all C code. For example, will

g++ -o testing test.c

produce an identical binary to

gcc -o testing test.c

in all circumstances?

More specifically, if they do not always create identical binaries, is there any reason that that could be a problem? Is it safe to always use g++ if I'm not sure about the code?


Solution

  • C is not a subset of C++.

    Try:

    foo.c

    int main() {
        int class = 0;
        return 0;
    }
    

    Anyway have fun here: Where is C not a subset of C++?