From: Georg F. <fu...@is...> - 2001-04-09 10:38:45
|
A File with the line #include <iostream.h> was not compiled if the suffix was ".c" and the compiler was called as "gcc". But was compiled with the suffix ".cc" by "gcc" and as ".c" by "g++". Greg Chicares wrote: > > Georg Fusz wrote: > > > I do NOT know a documentation about the flags set by "gcc" and "g++". > > touch foobar.c > gcc -dM -E foobar.c |less > g++ -dM -E foobar.c |less > This list the defined macros, but it does NOT list the default options of the compiler and the linker. > > Also: Every clean c-source is a valid c++-source. > > That depends on how 'clean' is defined. All the code in K&R is C++ > as well as C. But there are conforming C programs that are not C++. > Annex C to ISO/IEC standard 14882 lists oddities like this: > > C:\testing>copy con try_this.c > int main() {return main();} > ^Z > 1 file(s) copied > Really an interesting example of recursion. > C:\testing>gcc -c -Wall -ansi -pedantic try_this.c > This compiles! > C:\testing>g++ -c -Wall -ansi -pedantic try_this.c > try_this.c: In function `int main()': > try_this.c:1: warning: ANSI C++ forbids calling `main' from within program > try_this.c:1: warning: taking address of function `main' > > This example does seem to bear out your observation that > I get the warning also with mainrec.o: main_rec.c mainrec.mak g++ -Wall -ansi -pedantic -o $@ -c $< -Wall > > My experience tells me: > > > > The suffix of a file has *NO* meaning for [...] "g++". > > Changing the extension from 'c' to 'cpp' gives 'ANSI C++ forbids...' > whether you compile it with gcc or g++ . This means: gcc differs between files with the suffix ".c" and ".cpp" g++ works in the same way on files the suffix ".c" and ".cpp". All this gives no answer to the question: What is difference between "g++" and "gcc"? -- Georg Fusz Technische Universitaet Berlin, Germany Fon: Uni.: +49 30 314 26 884 privat: +49 30 815 30 32 Handy: +49 173 20 10 696 Homepage: http://www.cadlab.tu-berlin.de/~fusz/ |