From: khan AT xraylith DOT wisc DOT edu (Mumit Khan) Subject: Re: BUG: egcs-1.1-mingw32 - gcc -o hello hello.C 15 Oct 1998 17:36:36 -0700 Message-ID: <9810141928.AA11298.cygnus.gnu-win32@modi.xraylith.wisc.edu> References: <19981014170027 DOT 19134 DOT rocketmail AT send1d DOT yahoomail DOT com> To: earnie_boyd AT yahoo DOT com Cc: Mumit Khan , gw32 Earnie Boyd writes: > > According to the documentation for `gcc' in the `Overall Options' node > I can use .C, .cxx, .cpp, or .cc to indicate that the code is C++. > The only step of the process that is incorrect is in the absence of > the stdc++ library with the link command. Also I can specify the > switch `-x c++' which will also incorrectly not include the stdc++ > library. You misunderstand the documentation. When the program called "gcc" sees a ..cpp, it calls the C++ compiler (note the difference between compiler and driver), just as it calls the f77 compiler when it sees .[fF] extensions. Linking is something altogether different, and linking stdc++ without being told to automatically when using gcc is simply *wrong* (think binding to unneeded shared libraries, unnecessary static data, so on). also, question of orthogonality. $ gcc -c foo.cc <-- language can be deduced $ gcc -o foo foo.cc <-- language/runtime can be deduced $ gcc -o foo foo.o <-- language/runtime can not be deduced > Since the documentaion for gcc indicates that C++, as well as other > dialects, is recognized upon file suffix then the appropriate > libraries should be used or the documentation changed to indicate as > you've suggested. Compiling a language vs linking objects and hence providing the runtime required by those set of objects are treated differently in GCC (and rightly so). I agree that the documentation should be clearer in this regard, and spell out that it's talking about *compiling* a language. This behaviour is not likely to change however since it works and works very well. Of course, I'm always curious as to why someone would want to use gcc to compile/link C++ programs unless there is a special reason (I have some for linking, but never for compiling). Hope this clears it up. Please see g++ faq for further info on this. Regards, Mumit - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".