bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

stdint.h, C++ and __STDC_LIMIT_MACROS


From: Pedro Alves
Subject: stdint.h, C++ and __STDC_LIMIT_MACROS
Date: Sun, 01 Nov 2015 17:37:14 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0

Hello,

I'm working on porting GDB to C++03, and cross building for 
--host=x86_64-w64-mingw32 using
Fedora 20's g++ (gcc version 4.8.4 20141219 (Fedora MinGW 4.8.4-1.fc20)), I'm 
stumbling on:

 In file included from ../../src/gdb/../include/splay-tree.h:43:0,
                  from ../../src/gdb/dcache.c:26:
 build-gnulib/import/inttypes.h:61:3: error: #error "This file assumes that 
'int' has exactly 32 bits. Please report your platform and compiler to 
<address@hidden>."
  # error "This file assumes that 'int' has exactly 32 bits. Please report your 
platform and compiler to <address@hidden>."
    ^
 make: *** [dcache.o] Error 1

That's:

 #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 <address@hidden>."
 #endif

The fixed inttypes.h includes stdint.h, however mingw's stdint.h requires
defining __STDC_LIMIT_MACROS:

 /* 7.18.2  Limits of specified-width integer types */
 #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) ||   \
     defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L

 /* 7.18.2.1  Limits of exact-width integer types */
 #define INT8_MIN (-128)
 #define INT16_MIN (-32768)
 #define INT32_MIN (-2147483647 - 1)
 #define INT64_MIN  (-9223372036854775807LL - 1)
 (...)

and gnulib is deciding that the system's stdint.h is good enough
At least, I don't get a stdint.h replacement.  I do get an inttypes.h
replacement.

I'm pulling in the stdint and inttypes modules, and do AC_LANG_PUSH([C++])
before gl_EARLY -- in config.log I see autoconf is running tests with g++.

https://www.gnu.org/software/gnulib/manual/html_node/stdint_002eh.html
says:

" Portability problems fixed by Gnulib:
 (...)
 On some hosts that predate C++11, when using C++ one must
 define __STDC_CONSTANT_MACROS to make visible the definitions of constant 
macros
 such as INTMAX_C, and one must define __STDC_LIMIT_MACROS to make visible the
 definitions of limit macros such as INTMAX_MAX. "

I can work around this by defining __STDC_LIMIT_MACROS in gdb before
including stdint.h, but it sounds like I shouldn't need to.  Thus I wonder
what am I missing.

I'm attaching a gzip'ed config.log.

Thanks,
Pedro Alves

Attachment: config.log.gz
Description: application/gzip


reply via email to

[Prev in Thread] Current Thread [Next in Thread]