From 55a8bc593affc3565d63453d35773cdbf1046216 Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Wed, 14 May 2014 18:31:58 +0000 Subject: [PATCH] Using the -pedantic flag with gcc uncovered a series of warnings about non-standard C constructs in the code. This commit fixes them. git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1682 7f0cb862-5218-0410-a997-914c9d46530a --- progs/demos/CallbackMaker/CallbackMaker.c | 16 +++++----- src/fg_callbacks.c | 48 ++++++++++++++--------------- src/x11/fg_state_x11.c | 5 ++- 3 files changed, 36 insertions(+), 33 deletions(-) diff --git a/progs/demos/CallbackMaker/CallbackMaker.c b/progs/demos/CallbackMaker/CallbackMaker.c index 52044e3..a8cd18b 100644 --- a/progs/demos/CallbackMaker/CallbackMaker.c +++ b/progs/demos/CallbackMaker/CallbackMaker.c @@ -16,13 +16,13 @@ static int sequence_number = 0 ; int windows[CALLBACKMAKER_N_WINDOWS] = {0}; /* define status vars showing whether given callback has been called for given window */ -#define CALLBACK_CALLED_VAR(name) int name##_called[CALLBACKMAKER_N_WINDOWS] = {0}; -#define CALLBACK_0V(name) int name##_seq[CALLBACKMAKER_N_WINDOWS] = {-1}; CALLBACK_CALLED_VAR(name); -#define CALLBACK_1V(name,field) int name##_##field[CALLBACKMAKER_N_WINDOWS] = {-1}; CALLBACK_0V(name); -#define CALLBACK_2V(name,field1,field2) int name##_##field2[CALLBACKMAKER_N_WINDOWS] = {-1}; CALLBACK_1V(name,field1); -#define CALLBACK_3V(name,field1,field2,field3) int name##_##field3[CALLBACKMAKER_N_WINDOWS] = {-1}; CALLBACK_2V(name,field1,field2); -#define CALLBACK_4V(name,field1,field2,field3,field4) int name##_##field4[CALLBACKMAKER_N_WINDOWS] = {-1}; CALLBACK_3V(name,field1,field2,field3); -#define CALLBACK_5V(name,field1,field2,field3,field4,field5) int name##_##field5[CALLBACKMAKER_N_WINDOWS] = {-1}; CALLBACK_4V(name,field1,field2,field3,field4); +#define CALLBACK_CALLED_VAR(name) int name##_called[CALLBACKMAKER_N_WINDOWS] = {0} +#define CALLBACK_0V(name) int name##_seq[CALLBACKMAKER_N_WINDOWS] = {-1}; CALLBACK_CALLED_VAR(name) +#define CALLBACK_1V(name,field) int name##_##field[CALLBACKMAKER_N_WINDOWS] = {-1}; CALLBACK_0V(name) +#define CALLBACK_2V(name,field1,field2) int name##_##field2[CALLBACKMAKER_N_WINDOWS] = {-1}; CALLBACK_1V(name,field1) +#define CALLBACK_3V(name,field1,field2,field3) int name##_##field3[CALLBACKMAKER_N_WINDOWS] = {-1}; CALLBACK_2V(name,field1,field2) +#define CALLBACK_4V(name,field1,field2,field3,field4) int name##_##field4[CALLBACKMAKER_N_WINDOWS] = {-1}; CALLBACK_3V(name,field1,field2,field3) +#define CALLBACK_5V(name,field1,field2,field3,field4,field5) int name##_##field5[CALLBACKMAKER_N_WINDOWS] = {-1}; CALLBACK_4V(name,field1,field2,field3,field4) CALLBACK_2V(reshape,width,height); CALLBACK_2V(position,top,left); CALLBACK_1V(visibility,vis); @@ -39,7 +39,7 @@ CALLBACK_3V(passivemotion,x,y,mod); CALLBACK_1V(entry,state); CALLBACK_0V(close); /* menudestroy is registered on each menu, not a window */ -int menudestroy_called = 0 ; +int menudestroy_called = 0; /* menustatus and menustate are global callbacks, set for all menus at the same time */ int menustatus_called = 0; int menustate_called = 0; diff --git a/src/fg_callbacks.c b/src/fg_callbacks.c index 768358b..5ca3761 100644 --- a/src/fg_callbacks.c +++ b/src/fg_callbacks.c @@ -122,31 +122,31 @@ void FGAPIENTRY glut##a##Func( FGCB##b callback ) \ #define IMPLEMENT_CALLBACK_FUNC(a) IMPLEMENT_CALLBACK_FUNC_2NAME(a,a) /* Implement all these callback setter functions... */ -IMPLEMENT_CALLBACK_FUNC(Position); -IMPLEMENT_CALLBACK_FUNC(Keyboard); -IMPLEMENT_CALLBACK_FUNC(KeyboardUp); -IMPLEMENT_CALLBACK_FUNC(Special); -IMPLEMENT_CALLBACK_FUNC(SpecialUp); -IMPLEMENT_CALLBACK_FUNC(Mouse); -IMPLEMENT_CALLBACK_FUNC(MouseWheel); -IMPLEMENT_CALLBACK_FUNC(Motion); -IMPLEMENT_CALLBACK_FUNC_2NAME(PassiveMotion,Passive); -IMPLEMENT_CALLBACK_FUNC(Entry); +IMPLEMENT_CALLBACK_FUNC(Position) +IMPLEMENT_CALLBACK_FUNC(Keyboard) +IMPLEMENT_CALLBACK_FUNC(KeyboardUp) +IMPLEMENT_CALLBACK_FUNC(Special) +IMPLEMENT_CALLBACK_FUNC(SpecialUp) +IMPLEMENT_CALLBACK_FUNC(Mouse) +IMPLEMENT_CALLBACK_FUNC(MouseWheel) +IMPLEMENT_CALLBACK_FUNC(Motion) +IMPLEMENT_CALLBACK_FUNC_2NAME(PassiveMotion,Passive) +IMPLEMENT_CALLBACK_FUNC(Entry) /* glutWMCloseFunc is an alias for glutCloseFunc; both set the window's Destroy callback */ -IMPLEMENT_CALLBACK_FUNC_2NAME(Close,Destroy); -IMPLEMENT_CALLBACK_FUNC_2NAME(WMClose,Destroy); -IMPLEMENT_CALLBACK_FUNC(OverlayDisplay); -IMPLEMENT_CALLBACK_FUNC(WindowStatus); -IMPLEMENT_CALLBACK_FUNC(ButtonBox); -IMPLEMENT_CALLBACK_FUNC(Dials); -IMPLEMENT_CALLBACK_FUNC(TabletMotion); -IMPLEMENT_CALLBACK_FUNC(TabletButton); -IMPLEMENT_CALLBACK_FUNC(MultiEntry); -IMPLEMENT_CALLBACK_FUNC(MultiButton); -IMPLEMENT_CALLBACK_FUNC(MultiMotion); -IMPLEMENT_CALLBACK_FUNC(MultiPassive); -IMPLEMENT_CALLBACK_FUNC(InitContext); -IMPLEMENT_CALLBACK_FUNC(AppStatus); +IMPLEMENT_CALLBACK_FUNC_2NAME(Close,Destroy) +IMPLEMENT_CALLBACK_FUNC_2NAME(WMClose,Destroy) +IMPLEMENT_CALLBACK_FUNC(OverlayDisplay) +IMPLEMENT_CALLBACK_FUNC(WindowStatus) +IMPLEMENT_CALLBACK_FUNC(ButtonBox) +IMPLEMENT_CALLBACK_FUNC(Dials) +IMPLEMENT_CALLBACK_FUNC(TabletMotion) +IMPLEMENT_CALLBACK_FUNC(TabletButton) +IMPLEMENT_CALLBACK_FUNC(MultiEntry) +IMPLEMENT_CALLBACK_FUNC(MultiButton) +IMPLEMENT_CALLBACK_FUNC(MultiMotion) +IMPLEMENT_CALLBACK_FUNC(MultiPassive) +IMPLEMENT_CALLBACK_FUNC(InitContext) +IMPLEMENT_CALLBACK_FUNC(AppStatus) diff --git a/src/x11/fg_state_x11.c b/src/x11/fg_state_x11.c index 3aa19b1..206478f 100644 --- a/src/x11/fg_state_x11.c +++ b/src/x11/fg_state_x11.c @@ -155,6 +155,7 @@ int fgPlatformGlutGet ( GLenum eWhat ) else { XVisualInfo * visualInfo; + int result; #ifdef EGL_VERSION_1_0 EGLint vid = 0; XVisualInfo visualTemplate; @@ -166,13 +167,15 @@ int fgPlatformGlutGet ( GLenum eWhat ) visualTemplate.visualid = vid; visualInfo = XGetVisualInfo(fgDisplay.pDisplay.Display, VisualIDMask, &visualTemplate, &num_visuals); #else + { const GLXFBConfig fbconfig = fgStructure.CurrentWindow->Window.pContext.FBConfig; visualInfo = glXGetVisualFromFBConfig( fgDisplay.pDisplay.Display, fbconfig ); + } #endif - const int result = visualInfo->visual->map_entries; + result = visualInfo->visual->map_entries; XFree(visualInfo); -- 1.7.10.4