Reserved for implementation

Reading anwser from What are the rules for using underscores in c-id I came across the following quote:

From the C ++ 2003 standard:

17.4.3.2.1 Global Names [lib.global.names]

Certain sets of names and function signatures are always reserved for implementation:

  • Each name that contains a double underscore (_ _) or begins with an underscore followed by an uppercase letter (2.11) is reserved for implementation for any use.
  • Each name starting with an underscore is reserved for implementation for use as a name in the global namespace. 165

165) Such names are also reserved in the namespace :: std (17.4.3.1).

What exactly is meant by reserved for implementation ?

+4
source share
3 answers

An implementation here means a combination of a compiler (e.g. gcc, msvc, etc.), a standard library (says which features are included in the language), an operating system (Windows, Mac, etc.) and (Intel, ARM, etc.). d.).

Depending on the implementation, certain values ​​are defined that the compiler uses to create implementation-specific object code. for instance

__TARGET_ARCH_ARM is defined by RealView #Matches first case
_M_ARM is defined by Visual Studio #Matches second case

to determine the CPU manufacturer.

In short, these provisions are designed to discourage the use of macros of the specified format.

, n3797- > 17.6.5.3 , , :

#if preprocessing, .

:

#ifndef _M_ARM
#define _M_ARM // Say you're compiling for another platform
#endif

, , , . , __arm__ gcc .

+5

. , , .

+7

"" " ++". , ++: , , , , , ..

, , , . , __Foo, , __Foo , .

- ++, , .

, , .

: __FILE__, __cplusplus, __VA_ARGS__, . C ( ) (, _Bool).

+7

All Articles