g++ and link once sections.

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Sat Apr 1 01:59:00 GMT 2000


> But when I i compiled a couple of object files having template code  the
> resulting .o files do not have these sections . Am I missing out any
> other macros that are related to this ??

A number, including SUPPORTS_ONE_ONLY, SUPPORTS_WEAK, as well as the
setting of flag_weak. I'd really recommend to analyse this in a
debugger; set a breakpoint on supports_one_only, comdat_linkage, and
make_decl_one_only.

> Secondly I would like to know, is this a _must_  for  templates ??

No. You can make the templates static if you want. This increases code
size, of course. The only thing that might not work is block-static
variables in templates: for a specific instantiation, they should be
shared across translations units.

Regards,
Martin



More information about the Gcc mailing list