Is there any circumstance in which a valid C code will not be compiled correctly using g ++

Possible duplicate:
"C is a subset of C ++" → Where not? examples?

I know that C is a subset of C ++ (i.e. there is no valid C code that is not a valid C ++ code). My question is: is it compatible g++with all C code. For instance,

g++ -o testing test.c

create identical binary code for

gcc -o testing test.c

in all circumstances?

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

+5
source share
3 answers

C ++.

Try:

foo.c

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

: C ++?

+6

, :

  • C ++. C , ++. - . void* - .
  • g++ , . g++ ( ?) -ansi? -pedantic? std=<lang>?
  • , , , , : " ". , , , , .

, .

+3

C ++. . C99 ++, C89/90 ++ .

C89/90 , "" C ++,

  • ++
  • ++, C
  • Operator grammar (and the resulting operator priority) is slightly different between languages
  • Preliminary definitions are illegal in C ++
  • New keywords, implicit rule intin C ++ ...
  • And so on and so forth.
+2
source