Incomplete Type
#include "SDL_mixer.h" and it should be fine1,2.
The compiler is not capable of compiling SDL-related code without the SDL includes to tell it what those SDL refernces (Mix_Musi, Mix_LoadMUS, etc) refer too. See the SDL_Mixer Tutorial at kekkai.org/roger3 It has a complete example.
1 SDL Include file
2 Mix_LOadMUS
3 SDL Tutorial with complete example
--
Update: Using an Array of Music Items
This is an example of how to access a particular pointer to Mix_ Music from within a thread's code, or in any place lexically separate from the allocation of the pointer variable. An actual implementation may want to use dynamic array allocation and needs to add error handling for file-not-found or failed-to-load, etc.
MEnt.h A common iclude file for the initilization and thread modules:
#include <cstdlib>
#include "SDL.h"
#include "SDL_mixer.h"
enum { MAXENTRIES=1024 };
struct MEnt{
Mix_Music * music;
char *filename;
};
extern MEnt Marray[MAXENTRIES];
extern int Mselected;
Program initialization:
#include "MEnt.h"
// Alocate space for array of music items
MEnt Marray[MAXENTRIES];
int Mselected=-1;
In the thread's code,include:
#include "MEnt.h"
// Return a pointer for the selected music item:
// Allocate new Mix_Music* if not already done,
// otherwise return the already allocated pointer.
Mix_Music *getSelected(){
Mix_Music *music;
if(Mselected >= 0 && Mselected < MAXENTRIES){
struct MEnt ¤t=Marray[Mselected];
if(!(music=current.music) &&
(current.filename!=NULL))
music=current.music=
Mix_LoadMUS(current.filename);
}
return music;
}