From: Rcmaniac25 Date: Fri, 30 Jun 2017 23:21:21 +0000 (+0000) Subject: More explicit argument list for INVOKE_WCB callbacks X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=freeglut;a=commitdiff_plain;h=a67edfb64096e4da7f8b7d6cd34de78c7fc72c54 More explicit argument list for INVOKE_WCB callbacks git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1811 7f0cb862-5218-0410-a997-914c9d46530a --- diff --git a/src/fg_internal.h b/src/fg_internal.h index 7afb400..93ea3bc 100644 --- a/src/fg_internal.h +++ b/src/fg_internal.h @@ -713,7 +713,13 @@ do \ * typedef void (* FGCBEntryUC)( int, FGCBUserData ); * #define EXPAND_WCB_SUB_Entry(args, userData) EXPAND_WCB_ONE_OR_MORE(args, userData) */ +#define FG_COMPILER_SUPPORTS_VA_ARGS +#ifdef FG_COMPILER_SUPPORTS_VA_ARGS #define EXPAND_WCB_UNPARAN(...) __VA_ARGS__ +#else +#error "Compiler does not support varadic argument macros" +#endif + #define EXPAND_WCB_ZERO(args, userData) ( userData ) #define EXPAND_WCB_ONE_OR_MORE(args, userData) ( EXPAND_WCB_UNPARAN args, userData ) @@ -731,9 +737,10 @@ do \ * * The callback is invoked as: * - * callback( arg_list ); + * callback( arg_list, userData ); * - * ...so the parentheses are REQUIRED in the {arg_list}. + * ...where userData is added to the arg_list, but the parentheses + * are REQUIRED in the {arg_list}. * * NOTE that it does a sanity-check and also sets the * current window. @@ -748,7 +755,7 @@ do \ FGCB ## cbname ## UC func = (FGCB ## cbname ## UC)(FETCH_WCB( window, cbname )); \ FGCBUserData userData = FETCH_USER_DATA_WCB( window, cbname ); \ fgSetWindow( &window ); \ - func EXPAND_WCB( cbname )( arg_list, userData ); \ + func EXPAND_WCB( cbname )( arg_list, userData ); \ } \ } while( 0 ) #else @@ -759,7 +766,7 @@ do \ { \ fgSetWindow( &window ); \ FGCBUserData userData = FETCH_USER_DATA_WCB( window, cbname ); \ - ((FGCB ## cbname ## UC)FETCH_WCB( window, cbname )) EXPAND_WCB( cbname )( arg_list, userData ); \ + ((FGCB ## cbname ## UC)FETCH_WCB( window, cbname )) EXPAND_WCB( cbname )( arg_list, userData ); \ } \ } while( 0 ) #endif diff --git a/src/fg_main.c b/src/fg_main.c index 45f13f5..97c7a32 100644 --- a/src/fg_main.c +++ b/src/fg_main.c @@ -400,7 +400,7 @@ void fgProcessWork(SFG_Window *window) fgPlatformInitWork(window); /* Call init context callback */ - INVOKE_WCB( *window, InitContext, ()); + INVOKE_WCB( *window, InitContext, ( ) ); /* Lastly, check if we have a display callback, error out if not * This is the right place to do it, as the redisplay will be