Re: Re: Synopsis Question

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

> Luke Petre wrote:
>
>> Ok, so I looked at the ErrorHandler.cc problem again.  Here is a 
>> shorted version of the code, I added comments to the offending bits:
>
>
> 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.

> 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.
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.