Kyle R. Burton on 8 Oct 2003 16:22:02 -0000 |
> This is a question for anyone who knows some of the specifics with > compilers. > > I have a program that uses a line like > > cout << "stuff" << variable << endl; > > and I get linker errors when trying to compile this using gcc or cc, but not > when I use c++ as the compiling command. I have tried this on two RH9 and > one RH7.3 machines. > > What exactly is the difference btwn gcc <file.cpp> and c++ <file.cpp>? 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). hth, Kyle R. Burton -- ------------------------------------------------------------------------------ Wisdom and Compassion are inseparable. -- Christmas Humphreys mortis@voicenet.com http://www.voicenet.com/~mortis ------------------------------------------------------------------------------ _________________________________________________________________________ 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
|
|