From 9207839c800689c1c284cc0b6d8d5f7c6cfbff84 Mon Sep 17 00:00:00 2001 From: Stephen Gregoratto Date: Sun, 13 Aug 2023 17:50:39 +1000 Subject: [PATCH] Fix building on Windows - Drop linking opengl32/glew32.libs using `#pragma`s in favour of specifing the libraries at build time. - Use check for the `WIN32` macro when including Windows specific headers in `src/render_gl.c`. - Undefine the `min`, `max`, `near`, and `far` macros when building on Windows. --- src/render_gl.c | 14 +++++--------- src/utils.h | 6 ++++++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/render_gl.c b/src/render_gl.c index 435d43c..3a3642c 100644 --- a/src/render_gl.c +++ b/src/render_gl.c @@ -11,18 +11,14 @@ // Linux #elif defined(__unix__) #include -#elif defined(__MSYS__) - #include -// WINDOWS -#else + +// Windows +#elif defined(WIN32) #include #define GL3_PROTOTYPES 1 - #include - #pragma comment(lib, "glew32.lib") - - #include - #pragma comment(lib, "opengl32.lib") + #include + #include #endif diff --git a/src/utils.h b/src/utils.h index 861ef54..dcebb31 100644 --- a/src/utils.h +++ b/src/utils.h @@ -4,6 +4,12 @@ #include #include "types.h" +#ifdef WIN32 + #undef min + #undef max + #undef near + #undef far +#endif #if !defined(offsetof) #define offsetof(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT))