This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


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

Is __attribute__ ((constructor)) broken?



>From a post elsewhere

> The following code is a code fragment from a program of mine.   test_constructor() isn't
> being run.  I thought that test_constructor() was supposed to run before main.  It used to work in
> 2.8.1 on my system.
>
> target=powerpc-motorola-elf.
>
> Any clue?
>
> int testvalue = 0;
>
> // Why doesn't this constructor work?
> void test_constructor(void)   __attribute__ ((constructor));
>
> void test_constructor(void)
> {
>     testvalue = 1;
> }
>
> main()
> {
>
>     // some piece of code using testvalue and expecting it to be one.
> }


------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com


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