Identifiers starting with an underscore reserved according to the latest C ++ standard?

Possible duplicate:
What are the rules for using underscores in a C ++ id?

I am interested in the relevant sections from the standard (if any).

+1
source share
2 answers

Yes, when underlining is followed by another underscore or capital letter (i.e. for the #defines preprocessor or macros) or if the identifier is in the global namespace (§17.6.4.3.2):

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

- Each name containing a double underscore _ _ or beginning with an underscore followed by a capital letter (2.12) 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.

Please note that the first dot means that if two underscores appear anywhere in the identifier, even in the middle or at the end, this name is reserved. In addition, I would add (§17.6.4.3.5, my emphasis):

Literal suffix identifiers that do not begin with an underscore are reserved for future standardization.

+7
source

They are not reserved as for , but you should not use them, as compiler developers can use them to designate their own functions, so they may conflict with your function. Therefore, if you use my_class::_function , then there should be no errors, but writing a global function such as void _function() can generate a duplicate with one compiler!

0
source

Source: https://habr.com/ru/post/1012612/


All Articles