Re: [all pushed] Re: [PATCH 00/36] Support building GDB as a C++ program

asmwarrior
2015-03-16T07:15:16Z

On 2015-3-16 13:29, asmwarrior wrote:
> Now I see another build error which I don't know how to fix it.
>
> g++ -fpermissive -O0 -g -D__USE_MINGW_ACCESS -I. -I../../binutils-gdb/gdb -I../../binutils-gdb/gdb/common -I../../binutils-gdb/gdb/config -DLOCALEDIR="\"/mingw/share/locale\"" -DHAVE_CONFIG_H -I../../binutils-gdb/gdb/../include/opcode -I../../binutils-gdb/gdb/../opcodes/.. -I../../binutils-gdb/gdb/../readline/.. -I../bfd -I../../binutils-gdb/gdb/../bfd -I../../binutils-gdb/gdb/../include -I../libdecnumber -I../../binutils-gdb/gdb/../libdecnumber -I../../binutils-gdb/gdb/gnulib/import -Ibuild-gnulib/import -I/mingw/include -IE:/code/python27/include -IE:/code/python27/include -Wall -Wpointer-arith -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body -Wno-sign-compare -Wno-write-strings -Wno-narrowing -Wno-format -c -o dcache.o -MT dcache.o -MMD
> -MP -MF .deps/dcache.Tpo ../../binutils-gdb/gdb/dcache.c
> In file included from ../../binutils-gdb/gdb/../include/splay-tree.h:43:0,
> from ../../binutils-gdb/gdb/dcache.c:26:
> build-gnulib/import/inttypes.h:57:3: error: #error "This file assumes that 'int' has exactly 32 bits. Please report your platform and compiler to <bug-gnulib@gnu.org>."
> # error "This file assumes that 'int' has exactly 32 bits. Please report your platform and compiler to <bug-gnulib@gnu.org>."
> ^
>
> I use 32bit Windows, 32 bit GCC compiler(MinGW-Build GCC 4.8.2)
>
The error comes from: inttypes.h, which is under my build directory: F:\build_gdb\mybuildcpp\gdb\build-gnulib\import
It has:

#if !(INT_MIN == INT32_MIN && INT_MAX == INT32_MAX)
# error "This file assumes that 'int' has exactly 32 bits. Please report your platform and compiler to <bug-gnulib@gnu.org>."
#endif

I use some hack to see/print what's the value of those four macro definitions.
Methods comes from: http://stackoverflow.com/a/10227059/154911
so change code to
#if !(INT_MIN == INT32_MIN && INT_MAX == INT32_MAX)
/* definition to expand macro then apply to pragma message */
#define VALUE_TO_STRING(x) #x
#define VALUE(x) VALUE_TO_STRING(x)
#define VAR_NAME_VALUE(var) #var "=" VALUE(var)

#pragma message(VAR_NAME_VALUE(INT_MAX))
#pragma message(VAR_NAME_VALUE(INT32_MAX))
#pragma message(VAR_NAME_VALUE(INT_MIN))
#pragma message(VAR_NAME_VALUE(INT32_MIN))

# error "This file assumes that 'int' has exactly 32 bits. Please report your platform and compiler to <bug-gnulib@gnu.org>."
#endif

Then I just run the command line, add "-E" to the command line, also remove the "-o .....", I get the result:
#pragma message("INT_MAX" "=" "2147483647")
#pragma message("INT32_MAX" "=" "INT32_MAX")
#pragma message("INT_MIN" "=" "(-2147483647 - 1)")
#pragma message("INT32_MIN" "=" "INT32_MIN")

It turns out that INT32_MIN and INT32_MAX is not defined.
Question: where do I need to add those definitions of INT32_MIN and INT32_MAX?