Re: C++: conditional static data member possible?
- From: Carlos Moreno <moreno_at_mochima_dot_com@xxxxxxxxxxxxxx>
- Date: Fri, 24 Nov 2006 17:38:54 -0500
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
--
.
- Follow-Ups:
- Re: C++: conditional static data member possible?
- From: Paul Pluzhnikov
- Re: C++: conditional static data member possible?
- References:
- C++: conditional static data member possible?
- From: Carlos Moreno
- Re: C++: conditional static data member possible?
- From: Paul Pluzhnikov
- C++: conditional static data member possible?
- Prev by Date: Re: C++: conditional static data member possible?
- Next by Date: Blocking read() from a USB->Serial adapter.
- Previous by thread: Re: C++: conditional static data member possible?
- Next by thread: Re: C++: conditional static data member possible?
- Index(es):