Merge pull request #58 from rcmaniac25/bugfix/callback_code_isnt_iso_c_compliant
Fixed warnings on Linux where GCC under padantic complained ISO C casting wasn't legal
This commit is contained in:
commit
dfdb61f768
@ -203,39 +203,39 @@ do \
|
|||||||
#define IMPLEMENT_CALLBACK_FUNC_CB_ARG0(a,b) \
|
#define IMPLEMENT_CALLBACK_FUNC_CB_ARG0(a,b) \
|
||||||
static void fgh##a##FuncCallback( FGCBUserData userData ) \
|
static void fgh##a##FuncCallback( FGCBUserData userData ) \
|
||||||
{ \
|
{ \
|
||||||
FGCB##b callback = (FGCB##b)userData; \
|
FGCB##b* callback = (FGCB##b*)&userData; \
|
||||||
callback(); \
|
(*callback)(); \
|
||||||
}
|
}
|
||||||
#define IMPLEMENT_CALLBACK_FUNC_CB_ARG1(a,b) \
|
#define IMPLEMENT_CALLBACK_FUNC_CB_ARG1(a,b) \
|
||||||
static void fgh##a##FuncCallback( int arg1val, FGCBUserData userData ) \
|
static void fgh##a##FuncCallback( int arg1val, FGCBUserData userData ) \
|
||||||
{ \
|
{ \
|
||||||
FGCB##b callback = (FGCB##b)userData; \
|
FGCB##b* callback = (FGCB##b*)&userData; \
|
||||||
callback( arg1val ); \
|
(*callback)( arg1val ); \
|
||||||
}
|
}
|
||||||
#define IMPLEMENT_CALLBACK_FUNC_CB_ARG2(a,b) \
|
#define IMPLEMENT_CALLBACK_FUNC_CB_ARG2(a,b) \
|
||||||
static void fgh##a##FuncCallback( int arg1val, int arg2val, FGCBUserData userData ) \
|
static void fgh##a##FuncCallback( int arg1val, int arg2val, FGCBUserData userData ) \
|
||||||
{ \
|
{ \
|
||||||
FGCB##b callback = (FGCB##b)userData; \
|
FGCB##b* callback = (FGCB##b*)&userData; \
|
||||||
callback( arg1val, arg2val ); \
|
(*callback)( arg1val, arg2val ); \
|
||||||
}
|
}
|
||||||
#define IMPLEMENT_CALLBACK_FUNC_CB_ARG3_USER(a,b,arg1,arg2,arg3) \
|
#define IMPLEMENT_CALLBACK_FUNC_CB_ARG3_USER(a,b,arg1,arg2,arg3) \
|
||||||
static void fgh##a##FuncCallback( arg1 arg1val, arg2 arg2val, arg3 arg3val, FGCBUserData userData ) \
|
static void fgh##a##FuncCallback( arg1 arg1val, arg2 arg2val, arg3 arg3val, FGCBUserData userData ) \
|
||||||
{ \
|
{ \
|
||||||
FGCB##b callback = (FGCB##b)userData; \
|
FGCB##b* callback = (FGCB##b*)&userData; \
|
||||||
callback( arg1val, arg2val, arg3val ); \
|
(*callback)( arg1val, arg2val, arg3val ); \
|
||||||
}
|
}
|
||||||
#define IMPLEMENT_CALLBACK_FUNC_CB_ARG3(a,b) IMPLEMENT_CALLBACK_FUNC_CB_ARG3_USER(a,b,int,int,int)
|
#define IMPLEMENT_CALLBACK_FUNC_CB_ARG3(a,b) IMPLEMENT_CALLBACK_FUNC_CB_ARG3_USER(a,b,int,int,int)
|
||||||
#define IMPLEMENT_CALLBACK_FUNC_CB_ARG4(a,b) \
|
#define IMPLEMENT_CALLBACK_FUNC_CB_ARG4(a,b) \
|
||||||
static void fgh##a##FuncCallback( int arg1val, int arg2val, int arg3val, int arg4val, FGCBUserData userData ) \
|
static void fgh##a##FuncCallback( int arg1val, int arg2val, int arg3val, int arg4val, FGCBUserData userData ) \
|
||||||
{ \
|
{ \
|
||||||
FGCB##b callback = (FGCB##b)userData; \
|
FGCB##b* callback = (FGCB##b*)&userData; \
|
||||||
callback( arg1val, arg2val, arg3val, arg4val ); \
|
(*callback)( arg1val, arg2val, arg3val, arg4val ); \
|
||||||
}
|
}
|
||||||
#define IMPLEMENT_CALLBACK_FUNC_CB_ARG5(a,b) \
|
#define IMPLEMENT_CALLBACK_FUNC_CB_ARG5(a,b) \
|
||||||
static void fgh##a##FuncCallback( int arg1val, int arg2val, int arg3val, int arg4val, int arg5val, FGCBUserData userData ) \
|
static void fgh##a##FuncCallback( int arg1val, int arg2val, int arg3val, int arg4val, int arg5val, FGCBUserData userData ) \
|
||||||
{ \
|
{ \
|
||||||
FGCB##b callback = (FGCB##b)userData; \
|
FGCB##b* callback = (FGCB##b*)&userData; \
|
||||||
callback( arg1val, arg2val, arg3val, arg4val, arg5val ); \
|
(*callback)( arg1val, arg2val, arg3val, arg4val, arg5val ); \
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -252,7 +252,10 @@ void FGAPIENTRY glut##a##Func( FGCB##b callback ) \
|
|||||||
{ \
|
{ \
|
||||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glut"#a"Func" ); \
|
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glut"#a"Func" ); \
|
||||||
if( callback ) \
|
if( callback ) \
|
||||||
glut##a##FuncUcall( fgh##a##FuncCallback, (FGCBUserData)callback ); \
|
{ \
|
||||||
|
FGCB##b* reference = &callback; \
|
||||||
|
glut##a##FuncUcall( fgh##a##FuncCallback, *((FGCBUserData*)reference) ); \
|
||||||
|
} \
|
||||||
else \
|
else \
|
||||||
glut##a##FuncUcall( NULL, NULL ); \
|
glut##a##FuncUcall( NULL, NULL ); \
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,10 @@ void FGAPIENTRY glutTimerFunc( unsigned int timeOut, FGCBTimer callback, int tim
|
|||||||
{
|
{
|
||||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutTimerFunc" );
|
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutTimerFunc" );
|
||||||
if( callback )
|
if( callback )
|
||||||
glutTimerFuncUcall( timeOut, fghTimerFuncCallback, timerID, (FGCBUserData)callback );
|
{
|
||||||
|
FGCBTimer* reference = &callback;
|
||||||
|
glutTimerFuncUcall( timeOut, fghTimerFuncCallback, timerID, *((FGCBUserData*)reference) );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
glutTimerFuncUcall( timeOut, NULL, timerID, NULL );
|
glutTimerFuncUcall( timeOut, NULL, timerID, NULL );
|
||||||
}
|
}
|
||||||
@ -270,15 +273,18 @@ void FGAPIENTRY glutJoystickFuncUcall( FGCBJoystickUC callback, int pollInterval
|
|||||||
|
|
||||||
static void fghJoystickFuncCallback( unsigned int buttons, int axis0, int axis1, int axis2, FGCBUserData userData )
|
static void fghJoystickFuncCallback( unsigned int buttons, int axis0, int axis1, int axis2, FGCBUserData userData )
|
||||||
{
|
{
|
||||||
FGCBJoystick callback = (FGCBJoystick)userData;
|
FGCBJoystick* callback = (FGCBJoystick*)&userData;
|
||||||
callback( buttons, axis0, axis1, axis2 );
|
(*callback)( buttons, axis0, axis1, axis2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGAPIENTRY glutJoystickFunc( FGCBJoystick callback, int pollInterval )
|
void FGAPIENTRY glutJoystickFunc( FGCBJoystick callback, int pollInterval )
|
||||||
{
|
{
|
||||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickFunc" );
|
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickFunc" );
|
||||||
if( callback )
|
if( callback )
|
||||||
glutJoystickFuncUcall( fghJoystickFuncCallback, pollInterval, (FGCBUserData)callback );
|
{
|
||||||
|
FGCBJoystick* reference = &callback;
|
||||||
|
glutJoystickFuncUcall( fghJoystickFuncCallback, pollInterval, *((FGCBUserData*)reference) );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
glutJoystickFuncUcall( NULL, pollInterval, NULL );
|
glutJoystickFuncUcall( NULL, pollInterval, NULL );
|
||||||
}
|
}
|
||||||
|
@ -683,15 +683,16 @@ void FGAPIENTRY glutInitErrorFuncUcall( FGErrorUC callback, FGCBUserData userDat
|
|||||||
|
|
||||||
static void fghInitErrorFuncCallback( const char *fmt, va_list ap, FGCBUserData userData )
|
static void fghInitErrorFuncCallback( const char *fmt, va_list ap, FGCBUserData userData )
|
||||||
{
|
{
|
||||||
FGError callback = (FGError)userData;
|
FGError* callback = (FGError*)&userData;
|
||||||
callback( fmt, ap );
|
(*callback)( fmt, ap );
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGAPIENTRY glutInitErrorFunc( FGError callback )
|
void FGAPIENTRY glutInitErrorFunc( FGError callback )
|
||||||
{
|
{
|
||||||
if (callback)
|
if (callback)
|
||||||
{
|
{
|
||||||
glutInitErrorFuncUcall( fghInitErrorFuncCallback, (FGCBUserData)callback );
|
FGError* reference = &callback;
|
||||||
|
glutInitErrorFuncUcall( fghInitErrorFuncCallback, *((FGCBUserData*)reference) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -711,15 +712,16 @@ void FGAPIENTRY glutInitWarningFuncUcall( FGWarningUC callback, FGCBUserData use
|
|||||||
|
|
||||||
static void fghInitWarningFuncCallback( const char *fmt, va_list ap, FGCBUserData userData )
|
static void fghInitWarningFuncCallback( const char *fmt, va_list ap, FGCBUserData userData )
|
||||||
{
|
{
|
||||||
FGWarning callback = (FGWarning)userData;
|
FGWarning* callback = (FGWarning*)&userData;
|
||||||
callback( fmt, ap );
|
(*callback)( fmt, ap );
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGAPIENTRY glutInitWarningFunc( FGWarning callback )
|
void FGAPIENTRY glutInitWarningFunc( FGWarning callback )
|
||||||
{
|
{
|
||||||
if (callback)
|
if (callback)
|
||||||
{
|
{
|
||||||
glutInitWarningFuncUcall( fghInitWarningFuncCallback, (FGCBUserData)callback );
|
FGWarning* reference = &callback;
|
||||||
|
glutInitWarningFuncUcall( fghInitWarningFuncCallback, *((FGCBUserData*)reference) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -795,8 +795,8 @@ int FGAPIENTRY glutCreateMenuUcall( FGCBMenuUC callback, FGCBUserData userData )
|
|||||||
/* Standard glutCreateMenu */
|
/* Standard glutCreateMenu */
|
||||||
static void fghCreateMenuCallback( int menu, FGCBUserData userData )
|
static void fghCreateMenuCallback( int menu, FGCBUserData userData )
|
||||||
{
|
{
|
||||||
FGCBMenu callback = (FGCBMenu)userData;
|
FGCBMenu* callback = (FGCBMenu*)&userData;
|
||||||
callback( menu );
|
(*callback)( menu );
|
||||||
}
|
}
|
||||||
|
|
||||||
int FGAPIENTRY glutCreateMenu( FGCBMenu callback )
|
int FGAPIENTRY glutCreateMenu( FGCBMenu callback )
|
||||||
@ -806,7 +806,8 @@ int FGAPIENTRY glutCreateMenu( FGCBMenu callback )
|
|||||||
{
|
{
|
||||||
return glutCreateMenuUcall( NULL, NULL );
|
return glutCreateMenuUcall( NULL, NULL );
|
||||||
}
|
}
|
||||||
return glutCreateMenuUcall( fghCreateMenuCallback, (FGCBUserData)callback );
|
FGCBMenu* reference = &callback;
|
||||||
|
return glutCreateMenuUcall( fghCreateMenuCallback, *((FGCBUserData*)reference) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user