public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] sim: dv-sockser: move sim-main.h include after system includes
@ 2021-09-09  4:52 Mike Frysinger
  0 siblings, 0 replies; only message in thread
From: Mike Frysinger @ 2021-09-09  4:52 UTC (permalink / raw)
  To: gdb-patches

The sim-main.h header is a bit of a dumping ground.  Every arch can
(and many do) define all sorts of weird & common names that end up
conflicting with system headers.  So including it before the system
headers sets us up for pain.  v850 is a good example of this -- when
building for mingw, we see weird failures:

$ i686-w64-mingw32-gcc ... -c -o dv-sockser.o ../../../../sim/v850/../common/dv-sockser.c
In file included from ../../../../sim/v850/sim-main.h:11,
                 from ../../../../sim/v850/../common/dv-sockser.c:24:
../../../../sim/v850/../common/sim-base.h:97:32: error: expected ')' before '->' token
  97 | # define STATE_CPU(sd, n) ((sd)->cpu[0])
     |                                ^~

While gcc is unhelpful at first, running it through the preprocessor
by hand shows more details:

$ i686-w64-mingw32-gcc ... -E -dD -o dv-sockser.i ../../../../sim/v850/../common/dv-sockser.c
$ i686-w64-mingw32-gcc -c dv-sockser.i
In file included from /usr/i686-w64-mingw32/usr/include/minwindef.h:163,
                 from /usr/i686-w64-mingw32/usr/include/windef.h:9,
                 from /usr/i686-w64-mingw32/usr/include/windows.h:69,
                 from /usr/i686-w64-mingw32/usr/include/winsock2.h:23,
                 from ../../gnulib/import/sys/socket.h:684,
                 from ../../gnulib/import/netinet/in.h:43,
                 from ../../../../sim/v850/../common/dv-sockser.c:39:
/usr/i686-w64-mingw32/usr/include/winnt.h:4803:25: error: expected ‘)’ before ‘->’ token
 4803 |       DWORD State;
      |                         ^
      |                         )

This is because v850 sets up this common name:

All of this needs cleaning up someday, but since the dv-sockser code
definitely should be fixed in this way, lets do that now and unblock
the v850 code.
---
 sim/common/dv-sockser.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sim/common/dv-sockser.c b/sim/common/dv-sockser.c
index d47d428d535d..7950943d3669 100644
--- a/sim/common/dv-sockser.c
+++ b/sim/common/dv-sockser.c
@@ -21,8 +21,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 /* This must come before any other includes.  */
 #include "defs.h"
 
-#include "sim-main.h"
-
 #include <string.h>
 #include <signal.h>
 #include <stdlib.h>
@@ -42,6 +40,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <sys/select.h>
 #include <sys/socket.h>
 
+#include "sim-main.h"
 #include "sim-assert.h"
 #include "sim-options.h"
 
-- 
2.33.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-09  4:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-09  4:52 [PATCH] sim: dv-sockser: move sim-main.h include after system includes Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).