The compiler prepending an underscore is the expected behavior.
That happens to prevent name clashes.
I believe that you can use inline assembly to copy the value of a global variable originating from assembly code to a variable originating from C code, provided that you use the name of the latter with a prepended underscore within the inline assembly code block.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi folks!
I wish to access global symbols from my main:
But at linker stage I got an error:
The compiler(?) will add an underscore, because in the map file I can find the symbol:
How can I make this work?
regards,
Bert
Last edit: Bert Lange 2026-01-18
The compiler prepending an underscore is the expected behavior.
That happens to prevent name clashes.
I believe that you can use inline assembly to copy the value of a global variable originating from assembly code to a variable originating from C code, provided that you use the name of the latter with a prepended underscore within the inline assembly code block.
Ok, thanks Benedikt. This will do:
regards,
Bert