aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorthegeorg <thegeorg@yandex-team.ru>2022-03-07 13:20:48 +0300
committerthegeorg <thegeorg@yandex-team.ru>2022-03-07 13:20:48 +0300
commit7b23fec54e2fec0678c0806e255a00a1c97be46b (patch)
tree030ff871d9184a73110f005681d7b16138c5f232
parent03c0f57ecbe72821843b926b8e731b81e689bacd (diff)
downloadydb-7b23fec54e2fec0678c0806e255a00a1c97be46b.tar.gz
Fix -Wpragma-pack in trie.h
`#include ` and `#include ` modify current `#pragma pack` value and thus trigger `-Wpragma-pack` under clang-cl. As there is no way to implement packed structs via attributes, introduce proper compiler-specific variables in `` and use them to check whether we are compiling with MSVC. ref:e47cdb9c38eb305b9c5bcc5ad719e21ec52eb14c
-rw-r--r--util/system/compiler.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/util/system/compiler.h b/util/system/compiler.h
index b373edcc466..ba8ea4e3b70 100644
--- a/util/system/compiler.h
+++ b/util/system/compiler.h
@@ -1,5 +1,17 @@
#pragma once
+#if defined(_MSC_VER) && defined(__clang__)
+ #define _compiler_clang_cl_
+#elif defined(_MSC_VER)
+ #define _compiler_msvc_
+#elif defined(__clang__)
+ #define _compiler_clang_
+#elif defined(__GNUC__)
+ #define _compiler_gcc_
+#else
+ #warning("Current compiler is not supported by " __FILE__)
+#endif
+
#if defined(_MSC_VER)
#include <intrin.h>
#endif
@@ -157,7 +169,7 @@
#define Y_UNLIKELY(Cond) (Cond)
#endif
-#ifdef __GNUC__
+#if defined(_compiler_clang_) || defined(_compiler_clang_cl_) || defined(_compiler_gcc_)
#define Y_PACKED __attribute__((packed))
#else
#define Y_PACKED