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

Extensive usage of reserved identifiers #2517

Open
Erellu opened this issue Jul 13, 2022 · 3 comments
Open

Extensive usage of reserved identifiers #2517

Erellu opened this issue Jul 13, 2022 · 3 comments

Comments

@Erellu
Copy link

Erellu commented Jul 13, 2022

Before you go any further, maybe you want to link to very old issue. It was marked as completed in 2017, but as of e535556dbd31955e9205f9282602047034171c0f the problems are still there.

Several macros (and identifiers in general) use reserved names. This is undefined behaviour.

According to the standard (Cpp17 here):

20.5.4.3 Reserved names [reserved.names]
1 The C++ standard library reserves the following kinds of names:
—(1.1) macros
—(1.2) global names
—(1.3) names with external linkage
2 If a program declares or defines a name in a context where it is reserved, other than as explicitly allowed by this Clause, its behavior is undefined.

5.10 Identifiers
[...]
—(3.1) Each identifier that contains a double underscore __ or begins with an underscore followed by an uppercase letter is reserved to the implementation for any use.
—(3.2) Each identifier that begins with an underscore is reserved to the implementation for use as a name in the global namespace.

Header guards

Header guards used in (almost) each .h file in OGRE follow one of the following conventions:

  • __OgrePrerequisites_H__
  • __CompositorManager_H__
  • _ResourceManager_H_

All fall into 5.10 (3.2).

Export macro

_OgreExport, _OgrePrivate and probably other macros I'm not aware of fall into the 5.10 (3.1).

There may be other similar issues in other files, I did not check everything.

@paroj
Copy link
Member

paroj commented Jul 13, 2022

unless there is an actual conflict, I dont really care about this

@Erellu
Copy link
Author

Erellu commented Jul 13, 2022

@paroj Thanks for your answer. I'd feel rather uncomfortable to live with undefined behaviour in my code, but I understand there are things more interesting and more urgent to do in such projects. Anyway, thanks again!

@Erellu Erellu changed the title Extensive usage of reserve identifiers Extensive usage of reserved identifiers Jul 13, 2022
@elfring
Copy link

elfring commented Jan 8, 2024

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

No branches or pull requests

3 participants