This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Uninitialized variables

Hi,

 

I need to create uninitialized variables that are global in scope. Is there a way to do this? So far all of my global variables are initialized at run time by the compiler

 

Thx

Paul

 

  • You must be building with EABI.  Under the old COFF ABI, global variables are not initialized by default.  I presume you need to stay with EABI.

    So, the most straightforward method is to define the data in assembly.  It would look something like this ...

               .global   my_var1, my_var2            ; so other files can see these syms
               .bss      my_var1, 100, 4             ; define in .bss
    my_var2:   .usect    ".my_section", 100, 4       ; define in custom section
    

    Details on the .global,.bss, and .usect directives are contained the Assembly Language Tools User's Guide for your CPU family.  All of them can be found here.

    Thanks and regards,

    -George