This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

External variables in shared library constructor code


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]