public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* External variables in shared library constructor code
@ 2008-08-13 12:14 smokyboy
  0 siblings, 0 replies; only message in thread
From: smokyboy @ 2008-08-13 12:14 UTC (permalink / raw)
  To: gcc


Hi,

I have a problem using external variables in the constructor code of my
shared library. The constructor code is an init() function labeled by gcc
__attribute__((constructor)). In that function I make a reference to an
extern variable X provided by the driving app. The problem is that X is not
yet initialized at the moment init() is invoked, which is before main() is
entered.
A solution might be to introduce a init flag and move the initialization
code to some other exported function, but this is not really elegant. I will
appreciate any alternative suggestion.
-- 
View this message in context: http://www.nabble.com/External-variables-in-shared-library-constructor-code-tp18960710p18960710.html
Sent from the gcc - Dev mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-08-13 10:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-13 12:14 External variables in shared library constructor code smokyboy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).