[Piglit] [PATCH v3 05/19] Fixup APIENTRY macro on Apple

Paul Berry stereotype441 at gmail.com
Wed Mar 21 08:58:04 PDT 2012


The version of glut.h that ships on Mac OSX undefines the APIENTRY
macro.  APIENTRY is used on Windows builds to specify that GL
functions use the __stdcall calling convention, so it needs to be
defined to be the empty string on Mac OSX.  Previously this hasn't
been a problem because all of the GL function prototypes and typedefs
are finished by the time glut.h is included.  However, when we switch
to using piglit-dispatch instead of GLEW, there will be at least one
compilation unit (piglit-dispatch.c) which needs to use the APIENTRY
macro after including glut.h.

This patch works around the problem by redefining APIENTRY to the
correct value (which is the empty string) after including glut.h on
Apple builds.
---
 src/piglit/glut_wrap.h |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/piglit/glut_wrap.h b/src/piglit/glut_wrap.h
index c2ff532..e28bac9 100644
--- a/src/piglit/glut_wrap.h
+++ b/src/piglit/glut_wrap.h
@@ -45,6 +45,13 @@ extern "C" {
 #ifdef USE_GLUT
 #	ifdef __APPLE__
 #		include <GLUT/glut.h>
+
+		/* Apple's version of glut.h, annoyingly, #undefs
+		 * APIENTRY.  Redefine it so that Piglit code that
+		 * uses it won't get confused.
+		 */
+#		define APIENTRY
+
 #	else
 #		include <GL/glut.h>
 #		ifdef FREEGLUT
-- 
1.7.7.6



More information about the Piglit mailing list