Fixed warnings on Linux where GCC under padantic complained ISO C casting wasn't legal

(cherry picked from commit 13ed05fe8d)

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1833 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
dcnieho 2017-07-21 15:13:44 +00:00
parent eaabcd6b52
commit 5442c0abbf
4 changed files with 40 additions and 28 deletions

View File

@ -203,39 +203,39 @@ do \
#define IMPLEMENT_CALLBACK_FUNC_CB_ARG0(a,b) \
static void fgh##a##FuncCallback( FGCBUserData userData ) \
{ \
FGCB##b callback = (FGCB##b)userData; \
callback(); \
FGCB##b* callback = (FGCB##b*)&userData; \
(*callback)(); \
}
#define IMPLEMENT_CALLBACK_FUNC_CB_ARG1(a,b) \
static void fgh##a##FuncCallback( int arg1val, FGCBUserData userData ) \
{ \
FGCB##b callback = (FGCB##b)userData; \
callback( arg1val ); \
FGCB##b* callback = (FGCB##b*)&userData; \
(*callback)( arg1val ); \
}
#define IMPLEMENT_CALLBACK_FUNC_CB_ARG2(a,b) \
static void fgh##a##FuncCallback( int arg1val, int arg2val, FGCBUserData userData ) \
{ \
FGCB##b callback = (FGCB##b)userData; \
callback( arg1val, arg2val ); \
FGCB##b* callback = (FGCB##b*)&userData; \
(*callback)( arg1val, arg2val ); \
}
#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 ) \
{ \
FGCB##b callback = (FGCB##b)userData; \
callback( arg1val, arg2val, arg3val ); \
FGCB##b* callback = (FGCB##b*)&userData; \
(*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_ARG4(a,b) \
static void fgh##a##FuncCallback( int arg1val, int arg2val, int arg3val, int arg4val, FGCBUserData userData ) \
{ \
FGCB##b callback = (FGCB##b)userData; \
callback( arg1val, arg2val, arg3val, arg4val ); \
FGCB##b* callback = (FGCB##b*)&userData; \
(*callback)( arg1val, arg2val, arg3val, arg4val ); \
}
#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 ) \
{ \
FGCB##b callback = (FGCB##b)userData; \
callback( arg1val, arg2val, arg3val, arg4val, arg5val ); \
FGCB##b* callback = (FGCB##b*)&userData; \
(*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" ); \
if( callback ) \
glut##a##FuncUcall( fgh##a##FuncCallback, (FGCBUserData)callback ); \
{ \
FGCB##b* reference = &callback; \
glut##a##FuncUcall( fgh##a##FuncCallback, *((FGCBUserData*)reference) ); \
} \
else \
glut##a##FuncUcall( NULL, NULL ); \
}

View File

@ -83,7 +83,10 @@ void FGAPIENTRY glutTimerFunc( unsigned int timeOut, FGCBTimer callback, int tim
{
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutTimerFunc" );
if( callback )
glutTimerFuncUcall( timeOut, fghTimerFuncCallback, timerID, (FGCBUserData)callback );
{
FGCBTimer* reference = &callback;
glutTimerFuncUcall( timeOut, fghTimerFuncCallback, timerID, *((FGCBUserData*)reference) );
}
else
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 )
{
FGCBJoystick callback = (FGCBJoystick)userData;
callback( buttons, axis0, axis1, axis2 );
FGCBJoystick* callback = (FGCBJoystick*)&userData;
(*callback)( buttons, axis0, axis1, axis2 );
}
void FGAPIENTRY glutJoystickFunc( FGCBJoystick callback, int pollInterval )
{
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickFunc" );
if( callback )
glutJoystickFuncUcall( fghJoystickFuncCallback, pollInterval, (FGCBUserData)callback );
{
FGCBJoystick* reference = &callback;
glutJoystickFuncUcall( fghJoystickFuncCallback, pollInterval, *((FGCBUserData*)reference) );
}
else
glutJoystickFuncUcall( NULL, pollInterval, NULL );
}

View File

@ -683,15 +683,16 @@ void FGAPIENTRY glutInitErrorFuncUcall( FGErrorUC callback, FGCBUserData userDat
static void fghInitErrorFuncCallback( const char *fmt, va_list ap, FGCBUserData userData )
{
FGError callback = (FGError)userData;
callback( fmt, ap );
FGError* callback = (FGError*)&userData;
(*callback)( fmt, ap );
}
void FGAPIENTRY glutInitErrorFunc( FGError callback )
{
if (callback)
{
glutInitErrorFuncUcall( fghInitErrorFuncCallback, (FGCBUserData)callback );
FGError* reference = &callback;
glutInitErrorFuncUcall( fghInitErrorFuncCallback, *((FGCBUserData*)reference) );
}
else
{
@ -711,15 +712,16 @@ void FGAPIENTRY glutInitWarningFuncUcall( FGWarningUC callback, FGCBUserData use
static void fghInitWarningFuncCallback( const char *fmt, va_list ap, FGCBUserData userData )
{
FGWarning callback = (FGWarning)userData;
callback( fmt, ap );
FGWarning* callback = (FGWarning*)&userData;
(*callback)( fmt, ap );
}
void FGAPIENTRY glutInitWarningFunc( FGWarning callback )
{
if (callback)
{
glutInitWarningFuncUcall( fghInitWarningFuncCallback, (FGCBUserData)callback );
FGWarning* reference = &callback;
glutInitWarningFuncUcall( fghInitWarningFuncCallback, *((FGCBUserData*)reference) );
}
else
{

View File

@ -795,8 +795,8 @@ int FGAPIENTRY glutCreateMenuUcall( FGCBMenuUC callback, FGCBUserData userData )
/* Standard glutCreateMenu */
static void fghCreateMenuCallback( int menu, FGCBUserData userData )
{
FGCBMenu callback = (FGCBMenu)userData;
callback( menu );
FGCBMenu* callback = (FGCBMenu*)&userData;
(*callback)( menu );
}
int FGAPIENTRY glutCreateMenu( FGCBMenu callback )
@ -806,7 +806,8 @@ int FGAPIENTRY glutCreateMenu( FGCBMenu callback )
{
return glutCreateMenuUcall( NULL, NULL );
}
return glutCreateMenuUcall( fghCreateMenuCallback, (FGCBUserData)callback );
FGCBMenu* reference = &callback;
return glutCreateMenuUcall( fghCreateMenuCallback, *((FGCBUserData*)reference) );
}
/*