util: Prevent glheader.h from including <windows.h> by defining APIENTRY
authorYonggang Luo <luoyonggang@gmail.com>
Wed, 2 Nov 2022 16:00:55 +0000 (00:00 +0800)
committerMarge Bot <emma+marge@anholt.net>
Thu, 3 Nov 2022 16:07:31 +0000 (16:07 +0000)
commitf40afd1363f9eb586b8d8de59af16683beaf1692
treed3323749de05c8cb44eb93127379e1a707c112e1
parentafc3d5eff37ed4c0c6f9b1c4da1af60fe72b6b53
util: Prevent glheader.h from including <windows.h> by defining APIENTRY

When APIENTRY is not defined, GL/gl.h and GL/glext.h will automatically
include <windows.h>, 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 <windows.h> 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 <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Acked-by: Brian Paul brianp@vmware.com
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19472>
src/mesa/main/errors.c
src/mesa/main/glheader.h