From f40afd1363f9eb586b8d8de59af16683beaf1692 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Thu, 3 Nov 2022 00:00:55 +0800 Subject: [PATCH] util: Prevent glheader.h from including by defining APIENTRY MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When APIENTRY is not defined, GL/gl.h and GL/glext.h will automatically include , so we save the macro APIENTRY by push_macro and then define APIENTRY before include of GL/gl.h and GL/glext.h. After that we use pop_macro to recover the previous macro again. Because windows.h is not included by glheader.h, mesa/main/errors.c needs to include directly to prevent the following error: errors.c:98:10: error: implicit declaration of function 'OutputDebugStringA' [-Werror=implicit-function-declaration] 98 | OutputDebugStringA(buf); Signed-off-by: Yonggang Luo Reviewed-by: Jesse Natalie Acked-by: Brian Paul brianp@vmware.com Reviewed-by: Marek Olšák Part-of: --- src/mesa/main/errors.c | 3 +++ src/mesa/main/glheader.h | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index 938b6e7c4a3..cf057430928 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -41,6 +41,9 @@ #if DETECT_OS_ANDROID # include #endif +#if DETECT_OS_WINDOWS +# include +#endif static FILE *LogFile = NULL; diff --git a/src/mesa/main/glheader.h b/src/mesa/main/glheader.h index cf17f1ecd50..bf24f6f30d0 100644 --- a/src/mesa/main/glheader.h +++ b/src/mesa/main/glheader.h @@ -34,8 +34,19 @@ #define GL_GLEXT_PROTOTYPES +#if defined(_WIN32) && !defined(__CYGWIN__) +/* Prevent glheader.h from including by defining APIENTRY */ +#pragma push_macro("APIENTRY") +#ifndef APIENTRY +#define APIENTRY GLAPIENTRY +#endif #include "GL/gl.h" #include "GL/glext.h" +#pragma pop_macro("APIENTRY") +#else /* !(defined(_WIN32) && !defined(__CYGWIN__)) */ +#include "GL/gl.h" +#include "GL/glext.h" +#endif /* defined(_WIN32) && !defined(__CYGWIN__) */ #ifdef __cplusplus