From bd2c951e542d484ca308a0e8de6b1b420ffef2ce Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Thu, 12 May 2022 14:29:25 -0400 Subject: [PATCH] common: add macros to silence invalid offsetof warnings MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Implementations are not forced to support offsetof for non-trivial types in C++. gcc and clang both appear to support its use, but we should move away from that. unfortunately that is not easy since offsetof is used all over the place to use intrusive data structures. I am unsure of the proper fix for this at the moment. Signed-off-by: Jérémie Galarneau Change-Id: I6f2cedb0da235ff3756248f370add13d46438cec --- src/common/macros.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/common/macros.hpp b/src/common/macros.hpp index 42f7a94d1..8875462ed 100644 --- a/src/common/macros.hpp +++ b/src/common/macros.hpp @@ -272,6 +272,8 @@ void *memmove(T *d, const U *s, size_t n) = delete; _Pragma("GCC diagnostic ignored \"-Wformat-nonliteral\"") # define DIAGNOSTIC_IGNORE_LOGICAL_OP # define DIAGNOSTIC_IGNORE_DUPLICATED_BRANCHES +# define DIAGNOSTIC_IGNORE_INVALID_OFFSETOF + _Pragma("GCC diagnostic ignored \"-Winvalid-offsetof\"") #else /* GCC */ # define DIAGNOSTIC_IGNORE_SUGGEST_ATTRIBUTE_FORMAT \ @@ -282,6 +284,8 @@ void *memmove(T *d, const U *s, size_t n) = delete; _Pragma("GCC diagnostic ignored \"-Wlogical-op\"") # define DIAGNOSTIC_IGNORE_DUPLICATED_BRANCHES \ _Pragma("GCC diagnostic ignored \"-Wduplicated-branches\"") +# define DIAGNOSTIC_IGNORE_INVALID_OFFSETOF \ + _Pragma("GCC diagnostic ignored \"-Winvalid-offsetof\"") #endif /* Used to make specific C++ functions to C code. */ -- 2.34.1