0

I always wondered the function of the underscore character in c and assembly declarations (and wherever else). What's the meaning of a '_' in a statement like

MSVCRT!_output:
77c3f0f3 55               push    ebp
77c3f0f4 8bec             mov     ebp,esp
77c3f0f6 81ec50020000     sub     esp,0x250
77c3f0fc 33c0             xor     eax,eax
77c3f0fe 8945d8           mov     [ebp-0x28],eax
77c3f101 8945f0           mov     [ebp-0x10],eax
77c3f104 8945ec           mov     [ebp-0x14],eax
77c3f107 8b450c           mov     eax,[ebp+0xc]

or

#ifdef __unix__ /* __unix__ is usually defined by compilers targeting Unix systems */
# include <unistd.h>
#elif defined _WIN32 /* _Win32 is usually defined by compilers targeting 32 or 64 bit Windows systems */
# include <windows.h>
#endif

or

#if !(defined __LP64__ || defined __LLP64__) || defined _WIN32 && !defined _WIN64
    // we are compiling for a 32-bit system
#else
    // we are compiling for a 64-bit system
#endif

in C preprocessor? (These are just examples I've picked up on the fly=

And why and when is to use single or double underscore? Thanks a lot for your help! N.

thefourtheye
  • 233,700
  • 52
  • 457
  • 497
Neurophobos
  • 11
  • 1
  • 4
  • possible duplicate of [Why do C compilers prepend underscores to external names?](http://stackoverflow.com/questions/2627511/why-do-c-compilers-prepend-underscores-to-external-names) – 500 - Internal Server Error Mar 06 '14 at 12:48

1 Answers1

0

The underscore char in assembly has no special meaning. It is often used as a replacement for the space in the long descriptive labels: jumps_here_when_the_things_go_wrong:

Anyway, using underscore as a first char is probably just a habit from the C programming. The assembly programmers that come from another languages, does not use such a labels.

I, personally, use labels beginning with underscore only in libraries for the global labels that are for internal use only.

The count of the underscores used depends of how undesirable the use of this label from outside of the library - one underscore means "think what you make" and three underscores means "never, ever use it at all".

johnfound
  • 6,857
  • 4
  • 31
  • 60
  • Guys, I found what I was talking about! (too strange I've not been coming up with this page until now, it's been a long time I've been searching). It was about the include guard. Thank you for your interest sirs! – Neurophobos Mar 07 '14 at 08:08
  • Just to be sure at all...when you find something like the code of RtlAllocateHeap (http://msdn.microsoft.com/en-us/library/windows/hardware/ff552108%28v=vs.85%29.aspx) these underscores do not have any function as they do in include guards...they're just part of the variable name as any other character composing it, am I right? Thanks again! – Neurophobos Mar 07 '14 at 10:49