diff --git a/meson.build b/meson.build index aee9bb716b..a228a4862e 100644 --- a/meson.build +++ b/meson.build @@ -282,6 +282,8 @@ config.set('TAISEI_BUILDCONF_LOG_FATAL_MSGBOX', ( host_machine.system() == 'darwin' or not is_developer_build )) +# fixes some build issues on macOS, see PR #183 +config.set('TAISEI_BUILDCONF_DARWIN_SOURCE', (host_machine.system() == 'darwin')) config.set('TAISEI_BUILDCONF_DEBUG_OPENGL', get_option('debug_opengl')) install_docs = get_option('docs') and host_machine.system() != 'emscripten' diff --git a/src/util/compat.h b/src/util/compat.h index b327e88c9b..1d92e7a310 100644 --- a/src/util/compat.h +++ b/src/util/compat.h @@ -15,6 +15,13 @@ #define _POSIX_C_SOURCE 200809L #endif +// When compiling for Apple devices, the _POSIX_C_SOURCE option above messes with what header functions +// are available to the compiler, and it'll complain that things like timespec_get, etc don't exist +// even if Meson can detect them initially. Defining this fixes it. +#ifdef TAISEI_BUILDCONF_DARWIN_SOURCE +#define _DARWIN_C_SOURCE +#endif + // Common standard library headers #include #include