Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/11/12 13:37
Read: times


 
Msg Score: +1
 +1 Informative
#187662 - Underscore
Responding to: ???'s previous message
The C language per default adds an underscore to all symbols with external linkage.

So the function main() in the application will get the external linkage name _main.

Internal helper functions in the C runtime library uses a '_' prefix to their names, so they do not collide with end-user symbol names. The compiler will then too add a leading underscore, so a CRTL function _init_crtl() will get the external linkage name __init_crtl.

Assembler files do not add any underscore prefix.

In the end, this means that there are basically three different "name spaces" available.

One without leading underscores, used by assembler code.
One with a single leading underscore, used by end-user C code.
One with two leading underscores, used internally by the CRTL.

When mixing assembler and C, it is important to know that the assembler code must always explicitly add a '_' prefix when interacting with C symbols.

List of 5 messages in thread
TopicAuthorDate
SiLabs C8051F120 & SDCC Startup code            01/01/70 00:00      
   mind the underscore            01/01/70 00:00      
      Thank you, Maarten!            01/01/70 00:00      
         Underscore            01/01/70 00:00      
            Now it makes sense            01/01/70 00:00      

Back to Subject List