Meaning of "__"

Asked

Viewed 468 times

19

In the implementation of the Linux kernel, I came across this statement on line 89:

#define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })

I know that in C, symbols starting with a _ followed by a capital letter or other _ are reserved for implementation, which means this in practice?

2 answers

15

The use of two underscores ('__') in identifiers is reserved for internal compiler use according to the ANSI-C Technical Standard. In practice, this is done to avoid a collision with developer-defined names.

In C, symbols starting with an underscore followed by a letter uppercase or other underline are reserved for implementation. You as a C user should not create any symbols that begin with reserved sequences

Details

11


This means that if you declare a symbol (variable, function, macro, etc.) in this way, you may conflict with symbols exported by the standard compiler or library implementation.

For example, you can try to create a function:

void minha_funcao(int _Param);

But its implementation somewhere declares the macro:

#define _Param 1

In this way a syntax error will occur, because the Preprocessor will replace the macro with the value 1.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.