From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12382 invoked by alias); 14 Aug 2008 06:38:26 -0000 Received: (qmail 12372 invoked by uid 22791); 14 Aug 2008 06:38:25 -0000 X-Spam-Check-By: sourceware.org Received: from kuber.nabble.com (HELO kuber.nabble.com) (216.139.236.158) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 14 Aug 2008 06:37:29 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1KTWSd-0008FB-G3 for gcc-help@gcc.gnu.org; Wed, 13 Aug 2008 23:37:27 -0700 Message-ID: <18976389.post@talk.nabble.com> Date: Thu, 14 Aug 2008 07:16:00 -0000 From: smokyboy To: gcc-help@gcc.gnu.org Subject: External variables in shared library constructor code MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: smokyboy0@lycos.com X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2008-08/txt/msg00138.txt.bz2 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.