public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: smokyboy <smokyboy0@lycos.com>
To: gcc-help@gcc.gnu.org
Subject: External variables in shared library constructor code
Date: Thu, 14 Aug 2008 07:16:00 -0000	[thread overview]
Message-ID: <18976389.post@talk.nabble.com> (raw)


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-tp18976389p18976389.html
Sent from the gcc - Help mailing list archive at Nabble.com.

             reply	other threads:[~2008-08-14  6:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-14  7:16 smokyboy [this message]
2008-08-14 12:21 ` Eljay Love-Jensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=18976389.post@talk.nabble.com \
    --to=smokyboy0@lycos.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).