g++ filename
Indeed it helped. Now it compiles correcty. How could I have imagined to use g++ instead of gcc?? Where does apple say something like that?pepeleuepe said:try using:
Code:g++ filename
this will use the C++ compiler for GCC which should make your code compile correctly. I thought gcc would do the same thing, but it might cause some problems, so try the g++ command.
Hope that helps![]()
First, Apple has nothing to do with it; gcc/g++ are GNU open source projects which Apple has leveraged. You might notice the similarity between cc <-> gcc, and c++ <-> g++. A "C" compiler and a "C++" compiler.Soulstorm said:Indeed it helped. Now it compiles correcty. How could I have imagined to use g++ instead of gcc?? Where does apple say something like that?
And why gcc doesn't work?
gcc is the C compiler. g++ is the C++ compiler.Soulstorm said:And why gcc doesn't work?
Soulstorm said:And why gcc doesn't work?
More technically isn't C++ a superset of C? (since C came first).superbovine said:To add to whatever everyone said, C is a subset of C++ therefore a C compiler would not be able to parse C++.
I just thought gcc was the c++ compiler, not the plain c.therevolution said:gcc is the C compiler. g++ is the C++ compiler.
C++ has features that C does not. Consequently, the C compiler won't understand C++-specific code.
NuPowerbook said:More technically isn't C++ a superset of C? (since C came first).
Soulstorm said:I used "gcc <<filepath>>" but it shows errors of undefined symbols! Anyway, can you tell me how can I do it?
Nope; by default, gcc parses files as C files.Soulstorm said:I just thought gcc was the c++ compiler, not the plain c.
This isn't exactly true.therevolution said:gcc is the C compiler. g++ is the C++ compiler.
The GNU Compiler Collection (usually shortened to GCC) is a set of programming language compilers produced by the GNU Project. It is free software distributed by the Free Software Foundation (FSF) under the GNU GPL, and is a key component of the GNU toolchain. It is the standard compiler for the open source Unix-like operating systems, and certain proprietary operating systems derived therefrom such as Mac OS X.
Originally named the GNU C Compiler, because it only handled the C programming language, GCC was later extended to compile C++, Fortran, Ada, and others.
Yeah, I know. Read my comment right above yours. I thought it would be less confusing for a newbie to think of them as separate.ChrisBrightwell said: