aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJia Tan <jiat0218@gmail.com>2023-01-19 20:32:40 +0800
committerJia Tan <jiat0218@gmail.com>2023-01-19 20:32:40 +0800
commit82e3c968bfa10e3ff13333bd9cbbadb5988d6766 (patch)
tree8d5cecf9fcea248ac5da1aa27ea13970b3ef8243
parentCI: Reorder 32-bit build first for Linux autotool builds. (diff)
downloadxz-82e3c968bfa10e3ff13333bd9cbbadb5988d6766.tar.xz
tuklib_common: Define __has_warning if it is not defined.
clang supports the __has_warning macro to determine if the version of clang compiling the code supports a given warning. If we do not define it for other compilers, it may cause a preprocessor error.
-rw-r--r--src/common/tuklib_common.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/common/tuklib_common.h b/src/common/tuklib_common.h
index b1f531ea..8942e625 100644
--- a/src/common/tuklib_common.h
+++ b/src/common/tuklib_common.h
@@ -68,4 +68,11 @@
# define TUKLIB_DOSLIKE 1
#endif
+// Clang has a macro to check if the compiler supports a certain warning.
+// If this macro is used with a compiler that does not support this macro
+// (like gcc), then it will cause a preprocessor error.
+#ifndef __has_warning
+# define __has_warning(warn) 0
+#endif
+
#endif