Re: Compiling GDB on Windows using mingw64 toolchain

Jan Vrany
2018-03-06T11:04:36Z

Hi,

> This probably means that something did "#define wint_t int" before
> we get here (or some #undef doesn't trigger), which makes the
> compiler see:
>
> using ::int;
>

Yes, you're right. I dug a little deeper and tried to compile following
program:

--
#include <cwchar>
#include <string>

int main(int argc, char **argv) {
return 0;
}
--

using following:

--
x86_64-w64-mingw32-g++ -x c++ -g -O2 -I. -I../../gdb
-I../../gdb/common -I../../gdb/config
-DLOCALEDIR="\"/c/msys64/mingw64/share/locale\"" -DHAVE_CONFIG_H
-I../../gdb/../include/opcode -I../../gdb/../opcodes/.. -
I../../gdb/../zlib -I../bfd -I../../gdb/../bfd -I../../gdb/../include
-I../libdecnumber -I../../gdb/../libdecnumber -DTUI=1 -
I/c/msys64/mingw64/include -DMS_WIN64 -I/mingw64/include/python2.7
-Wall -Wpointer-arith -Wno-unused -Wunused-value -Wunused-function
-Wno-switch -Wno-char-subscripts -Wempty-body -Wunused-but-set-
parameter -Wunused-but-set-variable -Wno-sign-compare -Wno-narrowing
-Wno-error=maybe-uninitialized -Wno-format -c -o wchar.o -MT wchar.o
-MMD -MP -MF ./.deps/wchar.Tpo wchar.cpp
--

The above g++ invocation is essentially the same as used to compile
(failing) i386-tdep.c, just with i386-tdep.c replaced by wchar.c.
It fails with the very same error. Of course, the wchar.c test program
compiles just fine "normally".

So, it must be some of the command line switches that confuses the
compiler, most likely so that it takes some incompatible "system"
header.

When I remove the `-I../../gdb/gnulib/import -Ibuild-gnulib/import`
from the command, it compiles just fine.
It seems to me that the problem originats in
gdb/gnulib/import/wchar.in.h., line ~111.

How to fix that, I don't know (yet).

Thanks,

Jan