[MOAB-dev] namespace?

James Porter jvporter at wisc.edu
Tue Mar 2 14:47:10 CST 2010


On Tue, 2010-03-02 at 13:57 -0600, Jason Kraftcheck wrote:
> The disadvantages:
[snip]
>   3) Influences resolving of overloaded symbols by compiler.

I'd call this an advantage, though one that probably isn't particularly
useful in our case. In practice, I doubt it'll even come up, unless we
do something like 1) have apps with multiple versions of MOAB at once,
or 2) create functions like MOAB::swap(MOAB::interface&,
MOAB::interface&). 

>  o Should we use the namespace to implement symbol versioning?  This amounts
>    to something like:
>      #define MOAB_NS MOAB_ ## MOAB_VERSION_MAJOR
>      namespace MAOB = MOAB_NS;
>    Then everywhere in the MOAB source we use MOAB_NS rather than MOAB as
>    the namespace for declarations.  The user can use the 'MOAB' alias.
>    The result of this is that all the mangled symbols contain in the final
>    compiled library contain the major version number, such that linking to
>    an version of the library with the wrong major version number won't work.

I think we should use this, since it's one of the stated goals of
namespaces in C++.

There was also some discussion about this as a C++0x proposal:
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1344.pdf>.
Some of it isn't necessary for us, since we're probably not trying to
have multiple, simultaneous versions of MOAB, but skimming through it
might yield some useful information anyway. Your version (which is what
I think we should use) is option (2d) on page 8.

- Jim



More information about the moab-dev mailing list