Hello guys I was reading a C source and I found a notation like this:
__no_init __root extern volatile unsigned char var[10] @ 0x4000000;
But I've no idea what that __no_init __root means, is it standard C?
Thank you.
These are C language extensions used in some compilers targeting embedded systems (for example, IAR's AVR compiler).
__no_init
would mean that the compiler should not initialize the variable, and would be used when a variable is placed at a hardware register location and you don't want the start-up of the program to set the register to 0.
__root
is used to tell the compiler/linker that the variable or function should be kept in the binary image even if it isn't actually used in the program. This might be useful for debugging purposes and to 'size' a program while development is in progress.
These are macros that are likely defined inside your compiler toolchain. In my experience, __no_init usually means to tell the linker that the memory for this variable should not be initialized by the crt0 startup code that normally writes zero to global variables before main is called. __root often means that the linker should not discard the variable even if it thinks no code is using it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With