Re: Synopsis Question
Luke Petre <[email protected]>
| Newsgroups | gmane.comp.documentation.synopsis |
|---|---|
| Message-ID | <[email protected]> |
> I see. How do you compile synopsis with MSVC ? Did you set up project
> files ? Also, how do you deal with symbol exports ? I have been meaning
> to add the machinery to support declspec(dllexport) as well as the new
> gcc's visibility attributes, but none of this has happened yet. I'll
> set up an enhancement request for that right now.
>
>
Unfortunately nothing that is very useful to anyone except myself.
> Oh ? Does MSVC not support anonymous namespaces ?
With the original version of ErrorHandler.cc I was getting this compile
error:
error C2039: 'callback' : is not a member of 'operator``global namespace'''
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:
namespace Synopsis
{
struct ErrorHandler
{
typedef void (*Callback)();
ErrorHandler(Callback = 0);
};
}
namespace
{
Synopsis::ErrorHandler::Callback callback = 0;
void sighandler(int signo)
{
if (::callback) ::callback(); // MSVC doesn't know what callback is
here!!!
}
}
using namespace Synopsis;
ErrorHandler::ErrorHandler(Callback c)
{
::callback = c; // MSVC does find the variable 'callback' in the
anonymous namespace above
}
If I change the offending code to:
namespace
{
Synopsis::ErrorHandler::Callback callback = 0;
void sighandler(int signo)
{
if (callback) callback(); // MSVC now knows what you're talking about
}
}
Might I suggest this reorganization?
namespace Synopsis
{
struct ErrorHandler
{
typedef void (*Callback)();
ErrorHandler(Callback = 0);
};
}
namespace Synopsis
{
Synopsis::ErrorHandler::Callback callback = 0;
void sighandler(int signo)
{
if (callback) callback();
}
ErrorHandler::ErrorHandler(Callback c)
{
callback = c;
}
}
Now there aren't any anonymous namespaces. Everything is living happily
under the Synopsis namespace.
>
> It's all (still) in the sandbox/ area:
>
> Cxx/ is the new AST Translator (which will be exposed as
> 'Parsers.Cxx.Parser')
> cross/ is the new cross referencer (replacing 'Parsers.Cxx.link')
> bpl/ is a set of python bindings for the PTree and SymbolTable APIs,
> using boost.python
> wave/ is the new Cpp preprocessor (which will be exposed as
> 'Parsers.Cpp.Parser')
>
I'll be sure to check it out when I find some time.