This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Static linkage and anonymous namespace

> Ah, I see what you're up to.

Are you? :-) This patch is not about telling right from wrong, it is
about avoiding duplicate symbols that shouldn't be duplicate at link
time, and about reducing the set of exported symbols.

> So, the example you give is not legal C++.

Having read this particular passage of the standard many times, I
still don't see why that example (copied below) is illegal.

namespace { struct Foo{}; }
void print(Foo&){} 
std::vector<Foo> vfoo;

Foo has external linkage, and so do print and vfoo.
It is just that, in the assembler file, they are not exported symbols.

>  Therefore, I think we should do the more obvious thing: give it
> external linkage, as mandated by the standard.

Sure they have external linkage. The standard doesn't say anything
about the TREE_PUBLIC bit in g++.

>   o Do *not* give `void print(Foo&){} std::vector<Foo> vfoo'
>     internal linkage; it's just errorneous code so you shouldn't
>     be working that hard.

If that is indeed the case, I'll have to revise my code.

>   o Do *not* add the TREE_PRIVATE bit.

The bit is there, it is just wasted on identifiers :-)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]