Re: Re: Synopsis Question

Stefan Seefeld <[email protected]>
Newsgroups gmane.comp.documentation.synopsis
Message-ID <[email protected]>
Luke Petre wrote:

>> Thanks for looking into this ! Does the file compile if you simply
>> replace '::callback' by 'callback' everywhere, i.e. don't qualify
>> 'callback' any more ?
>>
> 
> Yes.  The only line that really matters is in the sighandler function.  
> The reference in the constructor of ErrorHandler compiles either way.  
> My 2c is that while you're in the anonymous namespace, the '::' is 
> forcing the compiler to only consider symbols outside of the current 
> namespace.  Or something strange like that.

Right. Unfortunately I don't remember why I introduced the qualification
in the first place. I'v removed it now, so everything should work fine.

>> That's right, but that defeats the purpose of the anonymous namespace to
>> deliberately hide the symbols it declares from the outside.
>>
> 
> Hrm.  If I follow what you're saying, the use of anonymous namespaces 
> here is to prevent something like this:
> 
> // file.cc
> namespace Synopsis
> {
>  extern ErrorHandler::Callback callback;
> }
> 
> void foo()
> {
>  if ( Synopsis::callback ) Synopsis::callback();
> }
> 
> I guess I've never really thought about enforcing restricted access like 
> that.  Pretty cool.

Exactly. It is the equivalent of C's 'static'.

Regards,
		Stefan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.