common: add macros to silence invalid offsetof warnings
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 12 May 2022 18:29:25 +0000 (14:29 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 13 Jun 2022 20:34:46 +0000 (16:34 -0400)
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 <jeremie.galarneau@efficios.com>
Change-Id: I6f2cedb0da235ff3756248f370add13d46438cec

src/common/macros.hpp

index 42f7a94d14648a35c6f84a1843fcb1db2de624c0..8875462edf284f379519947a2d4e43a60e7d554b 100644 (file)
@@ -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. */
This page took 0.026809 seconds and 5 git commands to generate.