[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: sid: gcc (GCC) 3.2.2 20030109 (Debian prerelease) strange!



On Sat, Jan 18, 2003 at 07:40:17PM +0100, Lukas Ruf wrote:
> * Colin Watson <cjwatson@debian.org> [2003-01-18 19:03]:
> > gcc 3.x has stricter behaviour than 2.x in certain cases. It looks very
> > much as if you're trying to link your program using 'gcc', which won't
> > work; you should use 'g++' instead, which will automatically pull in the
> > stdc++ library.
> 
> yeah.  Thanks for the hint, it worked.  However, I think this is a
> quite stupid behaviour of gcc 3.x -- it should automagically call the
> correct compiler/linker depending on the extension provided.

If you invoke 'gcc' to compile a .cpp file (and so on), it will indeed
treat it as a file containing C++ source. However, in that case you must
supply the correct linker arguments yourself.

Far from being stupid, this is in fact sometimes desired behaviour for
people who want finer control over the linking process. At work we use
our own C++ libraries rather than the standard library. As a result, we
actively prefer not to link against -lstdc++; instead, we link against
-lsupc++, which provides the basic runtime facilities like 'new' and
'delete'. Since it's possible to write your own new and delete
operators, some people might not even need this (?).

> Long time ago, I learned *.cc was c++, *.c was c -- obviously this
> does not hold anymore.

It does, just not in the way you expect.

Cheers,

-- 
Colin Watson                                  [cjwatson@flatline.org.uk]



Reply to: