Skip to content

Commit

Permalink
dynamic_mod.h: fix prototypes of MikMod_Init and MikMod_strerror:
Browse files Browse the repository at this point in the history
- old mikmod headers interchangingly used int and BOOL which led
  to confusions: MikMod_Init() returns error, not success.
- libmikmod >= 3.3.2 constified MikMod_Init() and MikMod_strerror().
- dynamic_mod.c: adjust casts accordingly.
  • Loading branch information
slouken committed Oct 16, 2017
1 parent 623f0ef commit dd1b6ee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions dynamic_mod.c
Expand Up @@ -59,7 +59,7 @@ int Mix_InitMOD()
return -1;
}
mikmod.MikMod_Init =
(BOOL (*)(CHAR*))
(int (*)(MIKMOD3_CONST CHAR*))
SDL_LoadFunction(mikmod.handle, "MikMod_Init");
if ( mikmod.MikMod_Init == NULL ) {
SDL_UnloadObject(mikmod.handle);
Expand Down Expand Up @@ -87,7 +87,7 @@ int Mix_InitMOD()
return -1;
}
mikmod.MikMod_strerror =
(char* (*)(int))
(MIKMOD3_CONST char* (*)(int))
SDL_LoadFunction(mikmod.handle, "MikMod_strerror");
if ( mikmod.MikMod_strerror == NULL ) {
SDL_UnloadObject(mikmod.handle);
Expand Down
11 changes: 9 additions & 2 deletions dynamic_mod.h
Expand Up @@ -23,18 +23,25 @@

#include "mikmod.h"

/* libmikmod >= 3.3.2 constified several funcs */
#if (LIBMIKMOD_VERSION < 0x030302)
#define MIKMOD3_CONST
#else
#define MIKMOD3_CONST const
#endif

typedef struct {
int loaded;
void *handle;

void (*MikMod_Exit)(void);
CHAR* (*MikMod_InfoDriver)(void);
CHAR* (*MikMod_InfoLoader)(void);
BOOL (*MikMod_Init)(CHAR*);
int (*MikMod_Init)(MIKMOD3_CONST CHAR*);
void (*MikMod_RegisterAllLoaders)(void);
void (*MikMod_RegisterDriver)(struct MDRIVER*);
int* MikMod_errno;
char* (*MikMod_strerror)(int);
MIKMOD3_CONST char* (*MikMod_strerror)(int);
void (*MikMod_free)(void*);
BOOL (*Player_Active)(void);
void (*Player_Free)(MODULE*);
Expand Down

0 comments on commit dd1b6ee

Please sign in to comment.