Mail Archives: cygwin/1998/10/15/17:36:36
Earnie Boyd <earnie_boyd AT yahoo DOT com> 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".
- Raw text -