This is the mail archive of the gcc-patches@gcc.gnu.org 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


>>>>> "Jason" == Jason Merrill <jason@cygnus.com> writes:

    Jason> Two points:

    Jason> 1) From this standpoint, it would also make sense to make
    Jason> functions that use types from an anonymous namespace
    Jason> internal; from Martin's description, it sounds like his
    Jason> patch would do that (though I haven't read it over).
    Jason> However,


    Jason> 2) The whole point of the anonymous namespace is to allow
    Jason> file-local things to be used in situations where a name
    Jason> with external linkage is required; for example, in template
    Jason> arguments.

Right.  In 

  namespace { void f() {} };

`f' has external linkage.  But, you can't call it from anywhere else.
So, we can make it `static' in the C sense.  So, it's fair to warn on:

  namespace { struct S {}; }
  void f(vector<S> vs);

but it's not fair to make that an *error*; it's actually legal, I think.

-- 
Mark Mitchell 			mark@markmitchell.com
Mark Mitchell Consulting	http://www.markmitchell.com


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