Boost logo

Boost Users :

Subject: Re: [Boost-users] [CONFIG] static const definitionsRe: Boost-users Digest, Vol 3373, Issue 1
From: John M. Dlugosz (mpbecey7gu_at_[hidden])
Date: 2013-02-28 19:05:31


On 2/28/2013 11:29 AM, boost-users-request-at-lists.boost.org |Boost/Allow to home| wrote:
> I've not come across that one before - do you have an example?
>
> John.
It's happening to me. I don't have time to make a full project to post, but from the
linker error I think that the ingredients are:

  * have an initialized static const member in a header file
  * used in more than one CPP file
  * "use" means something that isn't a compile-time value only; passing to a function
    taking a const& argument seems to do so. Maybe force the issue for testing by
    actually taking its address.
  * Define the (non-initialized) member in a different CPP file.
  * I was using a Debug build, in case that matters.
  * Visual Studio 2010, 32-bit code.

I get a linker error in that the symbol was already defined. Using it (as an lvalue)
defines it in such a way that duplicates are tolerated; an actual definition conflicts
with those.

It occurred to me that maybe it doesn't happen in Boost because the error does not occur
for templates, which are different in that the compiler must take care of duplicates from
different translation units, normally.



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