Bradley Molnar on 8 Oct 2003 18:09:02 -0000 |
thanks that clears it up. For a moment, I thought that I had forgotten how to do c++. -b -----Original Message----- From: plug-admin@lists.phillylinux.org [mailto:plug-admin@lists.phillylinux.org]On Behalf Of Mental Patient Sent: Wednesday, October 08, 2003 12:49 PM To: plug@lists.phillylinux.org Subject: Re: [PLUG] gcc vs cc vs c++ Kyle R. Burton wrote: > gcc/cc treats the source code as C, where that syntax involving cout > means something (very) different (left-shift). g++/c++ treats the > source code as C++ where operator overloading on the cout object (an > ostream) makes the left-shift operation mean something completely > different (equivalent to a function call, like write). > > The link error is related to the default libraries that are linked in, > for gcc/cc it's just libc (and maybe some others). For g++/c++ it should > include libstdc++ (which is where cout and other things live). > To follow up on this, its the same compiler. Its just that when you invoke gcc as g++, as Kyle points out, it goes into C++ mode. You can use gcc as gcc if you specify the language and link with the appropriate librarys. For the simple example of: #include <ostream.h> int main() { cout << "Hello, World" << endl; return 0; } You could compile this with either: g++ foo.cpp or gcc -std=gnu++98 -lstdc++ foo.cpp I'd recomnend not doing the latter. C++ is sufficiently complex that there are good reasons for g++ to exist. -- Mental (Mental@NeverLight.com) "The Torah... The Gospels... The Koran... Each claimed as the infallible word of GOD. Misquoted, misinterpreted, misunderstood, and misapplied. Maybe that's why he doesn't do any more interviews." - sinfest.net CARPE NOCTEM, QUAM MINIMUM CREDULA POSTERO. GPG public key: http://www.neverlight.com/pas/Mental.asc _________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.netisland.net/mailman/listinfo/plug-announce General Discussion -- http://lists.netisland.net/mailman/listinfo/plug
|
|