Use _Pragma to turn off invalid-offsetof warnings at appropriate places.
authorDavin McCall <davmac@davmac.org>
Sat, 6 Jan 2018 19:03:58 +0000 (19:03 +0000)
committerDavin McCall <davmac@davmac.org>
Sat, 6 Jan 2018 19:03:58 +0000 (19:03 +0000)
This means that we no longer need to build with -Wno-invalid-offsetof.

mconfig
src/control.h

diff --git a/mconfig b/mconfig
index b9a65e24fd757ecc068a58f8c2fa8504714c864c..fed7a66b2d48317c06908bfab7838d155d54141d 100644 (file)
--- a/mconfig
+++ b/mconfig
@@ -1,7 +1,7 @@
 # Linux (GCC). Note with GCC 5.x/6.x you must use the old ABI, with GCC 7.x you must use
 # the new ABI. See BUILD file for more information.
 CXX=g++
-CXXOPTS=-D_GLIBCXX_USE_CXX11_ABI=1 -std=gnu++11 -Os -Wall -Wno-invalid-offsetof -fno-rtti
+CXXOPTS=-D_GLIBCXX_USE_CXX11_ABI=1 -std=gnu++11 -Os -Wall -fno-rtti
 EXTRA_LIBS=
 BUILD_SHUTDOWN=yes
 SANITIZEOPTS=-fsanitize=address,undefined
index a6389f36b184e85bec578abb6cab262252d690b1..efcd72ad2a42102560870dec6888478606ef73f1 100644 (file)
@@ -218,8 +218,13 @@ class control_conn_t : private service_listener
 
 static rearm control_conn_cb(eventloop_t * loop, control_conn_watcher * watcher, int revents)
 {
+    // Get the address of the containing control_connt_t object:
+    _Pragma ("GCC diagnostic push")
+    _Pragma ("GCC diagnostic ignored \"-Winvalid-offsetof\"")
     char * cc_addr = (reinterpret_cast<char *>(watcher)) - offsetof(control_conn_t, iob);
     control_conn_t *conn = reinterpret_cast<control_conn_t *>(cc_addr);
+    _Pragma ("GCC diagnostic pop")
+
     if (revents & IN_EVENTS) {
         if (conn->data_ready()) {
             delete conn;