[LC++]template and gcc

Chris Vine chris at cvine.freeserve.co.uk
Tue Mar 26 10:43:07 UTC 2002


On Monday 25 March 2002 10:05 pm, Vincent Penquerc'h wrote:
> > gcc-2.7.2 to generate the required object code (the "template class
> > Running<int>;" approach wasn't reliable with that compiler).  I also
>
> Oh, sorry. I didn't know that.
> Do you know if it's because of a bug in this version, or because
> this method is undefined behavior ?

gcc-2.7.2 was way before templates were getting reasonably standardised (this 
is like 4 or 5 years ago), so it would probably be unfair to call it a bug.  
gcc-2.7.2 was known to have template problems.  Since then we have had egcs, 
gcc-2.95 and gcc-3.0.*.  All the latter have instantiated templates properly 
for me, but when you get into old habits ...

>> way, particularly with the adoption of the STL.  Presumably 
>> linkers have got 
>> a lot smarter in adopting techniques to avoid duplicate code. 
>
>That's the export keyword, and it's a bitch to get working 
>properly. But it's in the standard :) So one day, we'll maybe 
>have it working in our compilers... 

Actually, you don't need the export keyword to prevent redundant code in 
binaries, you just need smarter linkers to detect duplicate code at link 
time.  The export keyword is (I think) intended mainly to speed up compile 
time, rather than to reduce code size.

Chris.




More information about the tuxCPProgramming mailing list