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

Update Music.h for SDL_Mixer 2.8.1 #1242

Open
DanRStevens opened this issue Feb 26, 2025 · 0 comments
Open

Update Music.h for SDL_Mixer 2.8.1 #1242

DanRStevens opened this issue Feb 26, 2025 · 0 comments

Comments

@DanRStevens
Copy link
Collaborator

In Music.h there is a forward declaration:

typedef struct _Mix_Music Mix_Music;

The name _Mix_Music is a reserved identifier, since it starts with an underscore followed by an uppercase letter. This was reported to the SDL_Mixer project, which updated the name:

typedef struct Mix_Music Mix_Music;

The Arch Linux package has already updated to the new version. Unfortunately this causes the NAS2D build to break due to the incompatible name change.


Potentially we can revert to including the full SDL_mixer.h header file, rather than using a forward declare. We can possibly switch back to a forward declare once all supported builds have stabilized on the new version.


The problem of creating a forward declaration for an unknown struct is interesting.

https://stackoverflow.com/questions/7256436/forward-declarations-of-unnamed-struct

The idea presented there of created a new struct that derives from the old one was interesting. Unfortunately that's not possible when the base struct type is an incomplete type.

// h
struct MusicHandle;
// cpp
struct MusicHandle : public _Mix_Music {};

error: invalid use of incomplete type ‘struct _Mix_Music’


Maybe we shouldn't have Music as a standalone class, but rather something created or managed by MixerSDL. This might be similar to the idea of having RendererOpenGL own and manage Texture objects, rather than embedding that functionality in Image.

Related:

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

1 participant