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

Identifier _Mix_Music is reserved #605

Open
DanRStevens opened this issue Apr 14, 2024 · 0 comments
Open

Identifier _Mix_Music is reserved #605

DanRStevens opened this issue Apr 14, 2024 · 0 comments
Milestone

Comments

@DanRStevens
Copy link

The following type definition uses a reserved identifier _Mix_Music:

typedef struct _Mix_Music Mix_Music;

According to:
https://en.cppreference.com/w/cpp/language/identifiers

Identifiers that appear as a token or preprocessing token (i.e., not in user-defined-string-literal like operator ""id)(since C++11) of one of the following forms are reserved:

  • identifiers with a double underscore anywhere;
  • identifiers that begin with an underscore followed by an uppercase letter;
  • in the global namespace, identifiers that begin with an underscore.

Similarly, the GNU documentation states:
https://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html

In addition to the names documented in this manual, reserved names include all external identifiers (global functions and variables) that begin with an underscore (‘_’) and all identifiers regardless of use that begin with either two underscores or an underscore followed by a capital letter are reserved names.


When compiling code with Clang, the -Wreserved-identifier flag will warn about this name.


I noticed this when attempting to reduce transitive header includes in a project I was working on. I had tried to replace an include for SDL_mixer.h and a forward declare for Mix_Music, which required that I also use the name _Mix_Music. I occasionally compile my project with Clang's -Weverything flag and see what comes up.

@slouken slouken added this to the 2.10.0 milestone Apr 15, 2024
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

2 participants