Fix object/function pointer inconsistencies which are a problem for gcc 3.4.2.

Added GLUTproc type, returned by glutGetProcAddress().


git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@566 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
brianp 2005-02-11 15:18:04 +00:00
parent 3506d4ac40
commit e9be78b6fc
3 changed files with 153 additions and 143 deletions

View File

@ -112,7 +112,8 @@ FGAPI void FGAPIENTRY glutSolidCylinder( GLdouble radius, GLdouble height, GL
/* /*
* Extension functions, see freeglut_ext.c * Extension functions, see freeglut_ext.c
*/ */
FGAPI void * FGAPIENTRY glutGetProcAddress( const char *procName ); typedef void (*GLUTproc)();
FGAPI GLUTproc FGAPIENTRY glutGetProcAddress( const char *procName );
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -32,157 +32,158 @@
struct name_address_pair struct name_address_pair
{ {
const char *name; const char *name;
void *address; GLUTproc address;
}; };
static struct name_address_pair glut_functions[] = static struct name_address_pair glut_functions[] =
{ {
{ "glutInit", (void *) glutInit }, { "glutInit", (GLUTproc) glutInit },
{ "glutInitDisplayMode", (void *) glutInitDisplayMode }, { "glutInitDisplayMode", (GLUTproc) glutInitDisplayMode },
{ "glutInitDisplayString", (void *) glutInitDisplayString }, { "glutInitDisplayString", (GLUTproc) glutInitDisplayString },
{ "glutInitWindowPosition", (void *) glutInitWindowPosition }, { "glutInitWindowPosition", (GLUTproc) glutInitWindowPosition },
{ "glutInitWindowSize", (void *) glutInitWindowSize }, { "glutInitWindowSize", (GLUTproc) glutInitWindowSize },
{ "glutMainLoop", (void *) glutMainLoop }, { "glutMainLoop", (GLUTproc) glutMainLoop },
{ "glutCreateWindow", (void *) glutCreateWindow }, { "glutCreateWindow", (GLUTproc) glutCreateWindow },
{ "glutCreateSubWindow", (void *) glutCreateSubWindow }, { "glutCreateSubWindow", (GLUTproc) glutCreateSubWindow },
{ "glutDestroyWindow", (void *) glutDestroyWindow }, { "glutDestroyWindow", (GLUTproc) glutDestroyWindow },
{ "glutPostRedisplay", (void *) glutPostRedisplay }, { "glutPostRedisplay", (GLUTproc) glutPostRedisplay },
{ "glutPostWindowRedisplay", (void *) glutPostWindowRedisplay }, { "glutPostWindowRedisplay", (GLUTproc) glutPostWindowRedisplay },
{ "glutSwapBuffers", (void *) glutSwapBuffers }, { "glutSwapBuffers", (GLUTproc) glutSwapBuffers },
{ "glutGetWindow", (void *) glutGetWindow }, { "glutGetWindow", (GLUTproc) glutGetWindow },
{ "glutSetWindow", (void *) glutSetWindow }, { "glutSetWindow", (GLUTproc) glutSetWindow },
{ "glutSetWindowTitle", (void *) glutSetWindowTitle }, { "glutSetWindowTitle", (GLUTproc) glutSetWindowTitle },
{ "glutSetIconTitle", (void *) glutSetIconTitle }, { "glutSetIconTitle", (GLUTproc) glutSetIconTitle },
{ "glutPositionWindow", (void *) glutPositionWindow }, { "glutPositionWindow", (GLUTproc) glutPositionWindow },
{ "glutReshapeWindow", (void *) glutReshapeWindow }, { "glutReshapeWindow", (GLUTproc) glutReshapeWindow },
{ "glutPopWindow", (void *) glutPopWindow }, { "glutPopWindow", (GLUTproc) glutPopWindow },
{ "glutPushWindow", (void *) glutPushWindow }, { "glutPushWindow", (GLUTproc) glutPushWindow },
{ "glutIconifyWindow", (void *) glutIconifyWindow }, { "glutIconifyWindow", (GLUTproc) glutIconifyWindow },
{ "glutShowWindow", (void *) glutShowWindow }, { "glutShowWindow", (GLUTproc) glutShowWindow },
{ "glutHideWindow", (void *) glutHideWindow }, { "glutHideWindow", (GLUTproc) glutHideWindow },
{ "glutFullScreen", (void *) glutFullScreen }, { "glutFullScreen", (GLUTproc) glutFullScreen },
{ "glutSetCursor", (void *) glutSetCursor }, { "glutSetCursor", (GLUTproc) glutSetCursor },
{ "glutWarpPointer", (void *) glutWarpPointer }, { "glutWarpPointer", (GLUTproc) glutWarpPointer },
{ "glutEstablishOverlay", (void *) glutEstablishOverlay }, { "glutEstablishOverlay", (GLUTproc) glutEstablishOverlay },
{ "glutRemoveOverlay", (void *) glutRemoveOverlay }, { "glutRemoveOverlay", (GLUTproc) glutRemoveOverlay },
{ "glutUseLayer", (void *) glutUseLayer }, { "glutUseLayer", (GLUTproc) glutUseLayer },
{ "glutPostOverlayRedisplay", (void *) glutPostOverlayRedisplay }, { "glutPostOverlayRedisplay", (GLUTproc) glutPostOverlayRedisplay },
{ "glutPostWindowOverlayRedisplay", (void *) glutPostWindowOverlayRedisplay }, { "glutPostWindowOverlayRedisplay", (GLUTproc) glutPostWindowOverlayRedisplay },
{ "glutShowOverlay", (void *) glutShowOverlay }, { "glutShowOverlay", (GLUTproc) glutShowOverlay },
{ "glutHideOverlay", (void *) glutHideOverlay }, { "glutHideOverlay", (GLUTproc) glutHideOverlay },
{ "glutCreateMenu", (void *) glutCreateMenu }, { "glutCreateMenu", (GLUTproc) glutCreateMenu },
{ "glutDestroyMenu", (void *) glutDestroyMenu }, { "glutDestroyMenu", (GLUTproc) glutDestroyMenu },
{ "glutGetMenu", (void *) glutGetMenu }, { "glutGetMenu", (GLUTproc) glutGetMenu },
{ "glutSetMenu", (void *) glutSetMenu }, { "glutSetMenu", (GLUTproc) glutSetMenu },
{ "glutAddMenuEntry", (void *) glutAddMenuEntry }, { "glutAddMenuEntry", (GLUTproc) glutAddMenuEntry },
{ "glutAddSubMenu", (void *) glutAddSubMenu }, { "glutAddSubMenu", (GLUTproc) glutAddSubMenu },
{ "glutChangeToMenuEntry", (void *) glutChangeToMenuEntry }, { "glutChangeToMenuEntry", (GLUTproc) glutChangeToMenuEntry },
{ "glutChangeToSubMenu", (void *) glutChangeToSubMenu }, { "glutChangeToSubMenu", (GLUTproc) glutChangeToSubMenu },
{ "glutRemoveMenuItem", (void *) glutRemoveMenuItem }, { "glutRemoveMenuItem", (GLUTproc) glutRemoveMenuItem },
{ "glutAttachMenu", (void *) glutAttachMenu }, { "glutAttachMenu", (GLUTproc) glutAttachMenu },
{ "glutDetachMenu", (void *) glutDetachMenu }, { "glutDetachMenu", (GLUTproc) glutDetachMenu },
{ "glutDisplayFunc", (void *) glutDisplayFunc }, { "glutDisplayFunc", (GLUTproc) glutDisplayFunc },
{ "glutReshapeFunc", (void *) glutReshapeFunc }, { "glutReshapeFunc", (GLUTproc) glutReshapeFunc },
{ "glutKeyboardFunc", (void *) glutKeyboardFunc }, { "glutKeyboardFunc", (GLUTproc) glutKeyboardFunc },
{ "glutMouseFunc", (void *) glutMouseFunc }, { "glutMouseFunc", (GLUTproc) glutMouseFunc },
{ "glutMotionFunc", (void *) glutMotionFunc }, { "glutMotionFunc", (GLUTproc) glutMotionFunc },
{ "glutPassiveMotionFunc", (void *) glutPassiveMotionFunc }, { "glutPassiveMotionFunc", (GLUTproc) glutPassiveMotionFunc },
{ "glutEntryFunc", (void *) glutEntryFunc }, { "glutEntryFunc", (GLUTproc) glutEntryFunc },
{ "glutVisibilityFunc", (void *) glutVisibilityFunc }, { "glutVisibilityFunc", (GLUTproc) glutVisibilityFunc },
{ "glutIdleFunc", (void *) glutIdleFunc }, { "glutIdleFunc", (GLUTproc) glutIdleFunc },
{ "glutTimerFunc", (void *) glutTimerFunc }, { "glutTimerFunc", (GLUTproc) glutTimerFunc },
{ "glutMenuStateFunc", (void *) glutMenuStateFunc }, { "glutMenuStateFunc", (GLUTproc) glutMenuStateFunc },
{ "glutSpecialFunc", (void *) glutSpecialFunc }, { "glutSpecialFunc", (GLUTproc) glutSpecialFunc },
{ "glutSpaceballMotionFunc", (void *) glutSpaceballMotionFunc }, { "glutSpaceballMotionFunc", (GLUTproc) glutSpaceballMotionFunc },
{ "glutSpaceballRotateFunc", (void *) glutSpaceballRotateFunc }, { "glutSpaceballRotateFunc", (GLUTproc) glutSpaceballRotateFunc },
{ "glutSpaceballButtonFunc", (void *) glutSpaceballButtonFunc }, { "glutSpaceballButtonFunc", (GLUTproc) glutSpaceballButtonFunc },
{ "glutButtonBoxFunc", (void *) glutButtonBoxFunc }, { "glutButtonBoxFunc", (GLUTproc) glutButtonBoxFunc },
{ "glutDialsFunc", (void *) glutDialsFunc }, { "glutDialsFunc", (GLUTproc) glutDialsFunc },
{ "glutTabletMotionFunc", (void *) glutTabletMotionFunc }, { "glutTabletMotionFunc", (GLUTproc) glutTabletMotionFunc },
{ "glutTabletButtonFunc", (void *) glutTabletButtonFunc }, { "glutTabletButtonFunc", (GLUTproc) glutTabletButtonFunc },
{ "glutMenuStatusFunc", (void *) glutMenuStatusFunc }, { "glutMenuStatusFunc", (GLUTproc) glutMenuStatusFunc },
{ "glutOverlayDisplayFunc", (void *) glutOverlayDisplayFunc }, { "glutOverlayDisplayFunc", (GLUTproc) glutOverlayDisplayFunc },
{ "glutWindowStatusFunc", (void *) glutWindowStatusFunc }, { "glutWindowStatusFunc", (GLUTproc) glutWindowStatusFunc },
{ "glutKeyboardUpFunc", (void *) glutKeyboardUpFunc }, { "glutKeyboardUpFunc", (GLUTproc) glutKeyboardUpFunc },
{ "glutSpecialUpFunc", (void *) glutSpecialUpFunc }, { "glutSpecialUpFunc", (GLUTproc) glutSpecialUpFunc },
#if !TARGET_HOST_WINCE #if !TARGET_HOST_WINCE
{ "glutJoystickFunc", (void *) glutJoystickFunc }, { "glutJoystickFunc", (GLUTproc) glutJoystickFunc },
#endif /* !TARGET_HOST_WINCE */ #endif /* !TARGET_HOST_WINCE */
{ "glutSetColor", (void *) glutSetColor }, { "glutSetColor", (GLUTproc) glutSetColor },
{ "glutGetColor", (void *) glutGetColor }, { "glutGetColor", (GLUTproc) glutGetColor },
{ "glutCopyColormap", (void *) glutCopyColormap }, { "glutCopyColormap", (GLUTproc) glutCopyColormap },
{ "glutGet", (void *) glutGet }, { "glutGet", (GLUTproc) glutGet },
{ "glutDeviceGet", (void *) glutDeviceGet }, { "glutDeviceGet", (GLUTproc) glutDeviceGet },
{ "glutExtensionSupported", (void *) glutExtensionSupported }, { "glutExtensionSupported", (GLUTproc) glutExtensionSupported },
{ "glutGetModifiers", (void *) glutGetModifiers }, { "glutGetModifiers", (GLUTproc) glutGetModifiers },
{ "glutLayerGet", (void *) glutLayerGet }, { "glutLayerGet", (GLUTproc) glutLayerGet },
{ "glutBitmapCharacter", (void *) glutBitmapCharacter }, { "glutBitmapCharacter", (GLUTproc) glutBitmapCharacter },
{ "glutBitmapWidth", (void *) glutBitmapWidth }, { "glutBitmapWidth", (GLUTproc) glutBitmapWidth },
{ "glutStrokeCharacter", (void *) glutStrokeCharacter }, { "glutStrokeCharacter", (GLUTproc) glutStrokeCharacter },
{ "glutStrokeWidth", (void *) glutStrokeWidth }, { "glutStrokeWidth", (GLUTproc) glutStrokeWidth },
{ "glutBitmapLength", (void *) glutBitmapLength }, { "glutBitmapLength", (GLUTproc) glutBitmapLength },
{ "glutStrokeLength", (void *) glutStrokeLength }, { "glutStrokeLength", (GLUTproc) glutStrokeLength },
{ "glutWireSphere", (void *) glutWireSphere }, { "glutWireSphere", (GLUTproc) glutWireSphere },
{ "glutSolidSphere", (void *) glutSolidSphere }, { "glutSolidSphere", (GLUTproc) glutSolidSphere },
{ "glutWireCone", (void *) glutWireCone }, { "glutWireCone", (GLUTproc) glutWireCone },
{ "glutSolidCone", (void *) glutSolidCone }, { "glutSolidCone", (GLUTproc) glutSolidCone },
{ "glutWireCube", (void *) glutWireCube }, { "glutWireCube", (GLUTproc) glutWireCube },
{ "glutSolidCube", (void *) glutSolidCube }, { "glutSolidCube", (GLUTproc) glutSolidCube },
{ "glutWireTorus", (void *) glutWireTorus }, { "glutWireTorus", (GLUTproc) glutWireTorus },
{ "glutSolidTorus", (void *) glutSolidTorus }, { "glutSolidTorus", (GLUTproc) glutSolidTorus },
{ "glutWireDodecahedron", (void *) glutWireDodecahedron }, { "glutWireDodecahedron", (GLUTproc) glutWireDodecahedron },
{ "glutSolidDodecahedron", (void *) glutSolidDodecahedron }, { "glutSolidDodecahedron", (GLUTproc) glutSolidDodecahedron },
{ "glutWireTeapot", (void *) glutWireTeapot }, { "glutWireTeapot", (GLUTproc) glutWireTeapot },
{ "glutSolidTeapot", (void *) glutSolidTeapot }, { "glutSolidTeapot", (GLUTproc) glutSolidTeapot },
{ "glutWireOctahedron", (void *) glutWireOctahedron }, { "glutWireOctahedron", (GLUTproc) glutWireOctahedron },
{ "glutSolidOctahedron", (void *) glutSolidOctahedron }, { "glutSolidOctahedron", (GLUTproc) glutSolidOctahedron },
{ "glutWireTetrahedron", (void *) glutWireTetrahedron }, { "glutWireTetrahedron", (GLUTproc) glutWireTetrahedron },
{ "glutSolidTetrahedron", (void *) glutSolidTetrahedron }, { "glutSolidTetrahedron", (GLUTproc) glutSolidTetrahedron },
{ "glutWireIcosahedron", (void *) glutWireIcosahedron }, { "glutWireIcosahedron", (GLUTproc) glutWireIcosahedron },
{ "glutSolidIcosahedron", (void *) glutSolidIcosahedron }, { "glutSolidIcosahedron", (GLUTproc) glutSolidIcosahedron },
{ "glutVideoResizeGet", (void *) glutVideoResizeGet }, { "glutVideoResizeGet", (GLUTproc) glutVideoResizeGet },
{ "glutSetupVideoResizing", (void *) glutSetupVideoResizing }, { "glutSetupVideoResizing", (GLUTproc) glutSetupVideoResizing },
{ "glutStopVideoResizing", (void *) glutStopVideoResizing }, { "glutStopVideoResizing", (GLUTproc) glutStopVideoResizing },
{ "glutVideoResize", (void *) glutVideoResize }, { "glutVideoResize", (GLUTproc) glutVideoResize },
{ "glutVideoPan", (void *) glutVideoPan }, { "glutVideoPan", (GLUTproc) glutVideoPan },
{ "glutReportErrors", (void *) glutReportErrors }, { "glutReportErrors", (GLUTproc) glutReportErrors },
{ "glutIgnoreKeyRepeat", (void *) glutIgnoreKeyRepeat }, { "glutIgnoreKeyRepeat", (GLUTproc) glutIgnoreKeyRepeat },
{ "glutSetKeyRepeat", (void *) glutSetKeyRepeat }, { "glutSetKeyRepeat", (GLUTproc) glutSetKeyRepeat },
#if !TARGET_HOST_WINCE #if !TARGET_HOST_WINCE
{ "glutForceJoystickFunc", (void *) glutForceJoystickFunc }, { "glutForceJoystickFunc", (GLUTproc) glutForceJoystickFunc },
{ "glutGameModeString", (void *) glutGameModeString }, { "glutGameModeString", (GLUTproc) glutGameModeString },
{ "glutEnterGameMode", (void *) glutEnterGameMode }, { "glutEnterGameMode", (GLUTproc) glutEnterGameMode },
{ "glutLeaveGameMode", (void *) glutLeaveGameMode }, { "glutLeaveGameMode", (GLUTproc) glutLeaveGameMode },
{ "glutGameModeGet", (void *) glutGameModeGet }, { "glutGameModeGet", (GLUTproc) glutGameModeGet },
#endif /* !TARGET_HOST_WINCE */ #endif /* !TARGET_HOST_WINCE */
/* freeglut extensions */ /* freeglut extensions */
{ "glutMainLoopEvent", (void *) glutMainLoopEvent }, { "glutMainLoopEvent", (GLUTproc) glutMainLoopEvent },
{ "glutLeaveMainLoop", (void *) glutLeaveMainLoop }, { "glutLeaveMainLoop", (GLUTproc) glutLeaveMainLoop },
{ "glutCloseFunc", (void *) glutCloseFunc }, { "glutCloseFunc", (GLUTproc) glutCloseFunc },
{ "glutWMCloseFunc", (void *) glutWMCloseFunc }, { "glutWMCloseFunc", (GLUTproc) glutWMCloseFunc },
{ "glutMenuDestroyFunc", (void *) glutMenuDestroyFunc }, { "glutMenuDestroyFunc", (GLUTproc) glutMenuDestroyFunc },
{ "glutSetOption", (void *) glutSetOption }, { "glutSetOption", (GLUTproc) glutSetOption },
{ "glutSetWindowData", (void *) glutSetWindowData }, { "glutSetWindowData", (GLUTproc) glutSetWindowData },
{ "glutGetWindowData", (void *) glutGetWindowData }, { "glutGetWindowData", (GLUTproc) glutGetWindowData },
{ "glutSetMenuData", (void *) glutSetMenuData }, { "glutSetMenuData", (GLUTproc) glutSetMenuData },
{ "glutGetMenuData", (void *) glutGetMenuData }, { "glutGetMenuData", (GLUTproc) glutGetMenuData },
{ "glutBitmapHeight", (void *) glutBitmapHeight }, { "glutBitmapHeight", (GLUTproc) glutBitmapHeight },
{ "glutStrokeHeight", (void *) glutStrokeHeight }, { "glutStrokeHeight", (GLUTproc) glutStrokeHeight },
{ "glutBitmapString", (void *) glutBitmapString }, { "glutBitmapString", (GLUTproc) glutBitmapString },
{ "glutStrokeString", (void *) glutStrokeString }, { "glutStrokeString", (GLUTproc) glutStrokeString },
{ "glutWireRhombicDodecahedron", (void *) glutWireRhombicDodecahedron }, { "glutWireRhombicDodecahedron", (GLUTproc) glutWireRhombicDodecahedron },
{ "glutSolidRhombicDodecahedron", (void *) glutSolidRhombicDodecahedron }, { "glutSolidRhombicDodecahedron", (GLUTproc) glutSolidRhombicDodecahedron },
{ "glutWireSierpinskiSponge", (void *) glutWireSierpinskiSponge }, { "glutWireSierpinskiSponge", (GLUTproc) glutWireSierpinskiSponge },
{ "glutSolidSierpinskiSponge", (void *) glutSolidSierpinskiSponge }, { "glutSolidSierpinskiSponge", (GLUTproc) glutSolidSierpinskiSponge },
{ "glutWireCylinder", (void *) glutWireCylinder }, { "glutWireCylinder", (GLUTproc) glutWireCylinder },
{ "glutSolidCylinder", (void *) glutSolidCylinder }, { "glutSolidCylinder", (GLUTproc) glutSolidCylinder },
{ "glutGetProcAddress", (void *) glutGetProcAddress }, { "glutGetProcAddress", (GLUTproc) glutGetProcAddress },
{ "glutMouseWheelFunc", (void *) glutMouseWheelFunc }, { "glutMouseWheelFunc", (GLUTproc) glutMouseWheelFunc },
{ NULL, NULL } { NULL, NULL }
}; };
void *FGAPIENTRY glutGetProcAddress( const char *procName ) GLUTproc FGAPIENTRY
glutGetProcAddress( const char *procName )
{ {
/* Try GLUT functions first */ /* Try GLUT functions first */
int i; int i;
@ -193,9 +194,9 @@ void *FGAPIENTRY glutGetProcAddress( const char *procName )
/* Try core GL functions */ /* Try core GL functions */
#if TARGET_HOST_WIN32 || TARGET_HOST_WINCE #if TARGET_HOST_WIN32 || TARGET_HOST_WINCE
return( void * )wglGetProcAddress( ( LPCSTR )procName ); return(GLUTproc)wglGetProcAddress( ( LPCSTR )procName );
#elif TARGET_HOST_UNIX_X11 && defined( GLX_ARB_get_proc_address ) #elif TARGET_HOST_UNIX_X11 && defined( GLX_ARB_get_proc_address )
return(void * )glXGetProcAddressARB( ( const GLubyte * )procName ); return(GLUTproc)glXGetProcAddressARB( ( const GLubyte * )procName );
#else #else
return NULL; return NULL;
#endif #endif

View File

@ -359,6 +359,14 @@ struct tagSFG_WindowState
}; };
/*
* A generic function pointer. We should really use the GLUTproc type
* defined in freeglut_ext.h, but if we include that header in this file
* a bunch of other stuff (font-related) blows up!
*/
typedef void (*SFG_Proc)();
/* /*
* SET_WCB() is used as: * SET_WCB() is used as:
* *
@ -380,7 +388,7 @@ struct tagSFG_WindowState
do \ do \
{ \ { \
if( FETCH_WCB( window, cbname ) != func ) \ if( FETCH_WCB( window, cbname ) != func ) \
(((window).CallBacks[CB_ ## cbname]) = (void *) func); \ (((window).CallBacks[CB_ ## cbname]) = (SFG_Proc) func); \
} while( 0 ) } while( 0 )
/* /*
@ -532,7 +540,7 @@ struct tagSFG_Window
SFG_Context Window; /* Window and OpenGL context */ SFG_Context Window; /* Window and OpenGL context */
SFG_WindowState State; /* The window state */ SFG_WindowState State; /* The window state */
void *CallBacks[ TOTAL_CALLBACKS ]; /* Array of window callbacks */ SFG_Proc CallBacks[ TOTAL_CALLBACKS ]; /* Array of window callbacks */
void *UserData ; /* For use by user */ void *UserData ; /* For use by user */
SFG_Menu* Menu[ FREEGLUT_MAX_MENUS ]; /* Menus appended to window */ SFG_Menu* Menu[ FREEGLUT_MAX_MENUS ]; /* Menus appended to window */