gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

C/C++ > Initialization of volatile function/variable

#12832 - Rasputin77 - Fri Nov 28, 2003 4:30 pm

Hello ! (it s my 1st topic here ;) )

I ve a question about the initialization of variable and functions declared for example as :
unsigned char toto __attribute__ ((section (".ewram"))) = 1;

void fast_function(void) __attribute__ ((section (".iwram"), long_call)) {
...
}

the question is : When and how these volatile function/variable are initialized in RAM ? is it a piece of code inserted in (or before) main() exection ? or this variable/function are initialized at their first use ? or else ;) ?


Tkx !!!

#12835 - tepples - Fri Nov 28, 2003 4:40 pm

The init code (called before main()) copies the .iwram segment, which contains functions so labeled, to IWRAM. Then they're executed whenever they're called().
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#12836 - Rasputin77 - Fri Nov 28, 2003 4:44 pm

fast reply, tkx !