Initialization value of a global variable


#1

What is the initialization value of a global variable after a power cycle defined under the macro ADL_MEM_UNINIT?

Hi,

The initialization value of a global variable defined under the macro ADL_MEM_UNINIT is done by compiler.The global variables will be initialized by the compilers. In case of GCC the value of the variable will be initialized to the maximum value of the data type defined. For example if the variable is defined of the type U32, the global variable will be initialized to the value 4294967295.

This value is only during the 1st initialization as we cannot assign a default value or cannot initialize with a value when it is declared, in the code

Example :

ADL_MEM_UNINIT( u32 MyGlobal )

void main_task ( void ){ 
TRACE((1,"u32 %ld" , MyGlobal)); 
}

Will display
u32 4294967295 Which is 0xFFFFFFFF in hex

Following example shows,how to define the global varaible:

ADL_MEM_UNINIT( u32 MyGlobal )
void adl_main ( adl_InitType_e InitType )
{
...
MyGlobal = 500;
...
}

Thanks Awneil for the contribution for improving the FAQ article