Re: C++: conditional static data member possible?



Paul Pluzhnikov wrote:

Here is a (GNU-ld specific) solution:

- create libfoo.so as a linker script, containing

GROUP ( libfoo_nonshared.a libfoo_s.so )

- in libfoo_nonshared.a provide (in a single object) 'A::A()' and
'const int A::used = 1'

- in libfoo_s.so provide 'const int A::used = 0'

Now, any application that needs 'A::A()' and links against libfoo.so,
will "pull in" the object containing 'A::A()' from libfoo_nonshared.a, and will get A::used == 1.

Any application that doesn't need A::A() will get A::used == 0
from libfoo_s.so

Why do I have such guarantee?? Don't these definitions clash if
for some reason I need *both* linked?

Thanks,

Carlos
--
.