Boost logo

Boost Users :

Subject: Re: [Boost-users] [CONFIG] static const definitions
From: Edward Diener (eldiener_at_[hidden])
Date: 2013-02-26 22:14:49


On 02/26/2013 08:43 AM, John M. Dlugosz wrote:
> I ran into a compiler idiosyncrasy, and my usual approach is to use the
> macros and mechanisms that Boost does in the same situation.
> But I can't find what I'm looking for in the Boost.Config
> documentation. So what does Boost do here?
>
> I found that the VS2010 compiler automatically defines a static const
> member that has been initialized inline in the declaration, and thus
> supplying a (required!) definition without the initializer at namespace
> or file scope will give a linker error if the class declaration is in a
> header that appears in more than one translation unit.
>
> At least one other compiler does in fact require the bare definition to
> link properly, and doesn't generate it automatically as an enhancement.
> So I need to make these definitions conditional based on the platform
> (and perhaps the exact compiler version? That's why I like to use the
> existing config knowledge base!)
>
> I see that Boost has BOOST_STATIC_CONSTANT but that is for compilers
> that don't have the in-class initialization at all.
>
> So if Boost is using such constructs, how does it deal with the linker
> idiosyncrasy?

You could always not initialize inline and therefore always supply a
separate definition.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net