Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reserved identifier violation #167

Open
elfring opened this issue May 29, 2016 · 4 comments
Open

reserved identifier violation #167

elfring opened this issue May 29, 2016 · 4 comments

Comments

@elfring
Copy link

elfring commented May 29, 2016

I would like to point out that identifiers like "HAMMER_ALLOCATOR__H__" and "mm__" do eventually not fit to the expected naming convention of the C++ language standard.
Would you like to adjust your selection for unique names?

@uucidl
Copy link

uucidl commented Jul 24, 2016

I looked up the reference for that and found:
http://en.cppreference.com/w/cpp/language/identifiers#In_declarations

In declarations
An identifier can be used to name objects, references, functions, enumerators, types, class members, namespaces, templates, template specializations, parameter packs, goto labels, and other entities, with the following exceptions:
the identifiers that are keywords cannot be used for other purposes;
the identifiers with a double underscore anywhere are reserved;
the identifiers that begin with an underscore followed by an uppercase letter are reserved;
the identifiers that begin with an underscore are reserved in the global namespace.
"Reserved" here means that the standard library headers #define or declare such identifiers for their internal needs, the compiler may predefine non-standard identifiers of that kind, and that name mangling algorithm may assume that some of these identifiers are not in use. If the programmer uses such identifiers, the behavior is undefined.
In addition, it's undefined behavior to #define or #undef names identical to keywords. If at least one standard library header is included, it's undefined behavior to #define or #undef identifiers identical to names declared in any standard library header.

@pesco
Copy link

pesco commented Jul 25, 2016

Do we know any platforms where this causes a problem?

@elfring
Copy link
Author

elfring commented Jul 25, 2016

How do you think about to avoid that this software depends on undefined behaviour?

@pesco
Copy link

pesco commented Jul 26, 2016

Would you like to submit a pull request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants