Found by clang (warning introduced in r258128), reported by Idwer.
Signed-off-by: Stefan Tauner stefan.tauner@alumni.tuwien.ac.at --- platform.h | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/platform.h b/platform.h index c5a52ef..b58c303 100644 --- a/platform.h +++ b/platform.h @@ -24,10 +24,24 @@ #ifndef __PLATFORM_H__ #define __PLATFORM_H__ 1
-// Helper defines for operating systems -#define IS_LINUX (defined(__gnu_linux__) || defined(__linux__)) -#define IS_MACOSX (defined(__APPLE__) && defined(__MACH__)) /* yes, both. */ -#define IS_WINDOWS (defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(__WINDOWS__)) +/* Helper defines for operating systems. + * This may seem complicated but the following would be undefined behavior: + * #define IS_LINUX (defined(__gnu_linux__) || defined(__linux__)) */ +#if defined(__gnu_linux__) || defined(__linux__) + #define IS_LINUX (1) +#else + #define IS_LINUX (0) +#endif +#if defined(__APPLE__) && defined(__MACH__) /* yes, both. */ + #define IS_MACOSX (1) +#else + #define IS_MACOSX (0) +#endif +#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(__WINDOWS__) + #define IS_WINDOWS (1) +#else + #define IS_WINDOWS (0) +#endif
// Likewise for target architectures #if defined (__i386__) || defined (__x86_64__) || defined(__amd64__)