Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@ericsson.com>
To: Pedro Alves <palves@redhat.com>, <gdb-patches@sourceware.org>
Subject: Re: [PATCH 07/11] [C++/mingw] Define __STDC_CONSTANT_MACROS / __STDC_LIMIT_MACROS for stdint.h
Date: Mon, 02 Nov 2015 20:47:00 -0000	[thread overview]
Message-ID: <5637CBC9.2050404@ericsson.com> (raw)
In-Reply-To: <1446492970-21432-8-git-send-email-palves@redhat.com>

On 15-11-02 02:36 PM, Pedro Alves wrote:
> 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)), stumbles on
> many instances of:
> 
>  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 <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>."
>     ^
>  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 <bug-gnulib@gnu.org>."
>  #endif
> 
> The issue is that on some hosts that predate C++11, when using C++ one
> must define __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS to make visible
> the definitions of INTMAX_C / INTMAX_MAX etc.
> 
> This was a C99 requirement that later C++11 -- the first to define
> stdint.h -- removed, and then C11 removed it as well.
> 
> https://www.gnu.org/software/gnulib/manual/html_node/stdint_002eh.html
> says that gnulib's stdint.h fixes this, but because we run gnulib's
> configure tests with a C compiler, gnulib determines that mingw's
> stdint.h is C99-compliant, and doesn't actually replace it.  Actually,
> even though configuring gnulib with a C++ compiler does result in
> gnulib replacing stdint.h, the resulting replacement is broken for
> mingw, because it defines uintptr_t incorrectly.  I sent a gnulib
> patch upstream to fix that, here:
> 
>   https://lists.gnu.org/archive/html/bug-gnulib/2015-11/msg00004.html
> 
> but then even with that, gnulib still stumbles on other
> configured-with-C++-compiler problems.
> 
> So for now, until gnulib + C++ is fixed upstream and then gdb's copy
> is updated, which may take a while, I think it's best to keep
> configuring gnulib in C, and define
> __STDC_LIMIT_MACROS/__STDC_CONSTANT_MACROS ourselves, just like C99
> intended.
> 
> gdb/ChangeLog:
> 2015-11-01  Pedro Alves  <palves@redhat.com>
> 
> 	* common/common-defs.h (__STDC_CONSTANT_MACROS)
> 	(__STDC_LIMIT_MACROS): Define before including stdint.h.
> ---
>  gdb/common/common-defs.h | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/gdb/common/common-defs.h b/gdb/common/common-defs.h
> index 2be0d7d..59b1887 100644
> --- a/gdb/common/common-defs.h
> +++ b/gdb/common/common-defs.h
> @@ -31,7 +31,23 @@
>  #include <stdio.h>
>  #include <stdlib.h>
>  #include <stddef.h>
> +
> +/* From:
> +    https://www.gnu.org/software/gnulib/manual/html_node/stdint_002eh.html
> +
> +   "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."
> +
> +   gnulib doesn't fix this for us correctly yet.  See:
> +     https://lists.gnu.org/archive/html/bug-gnulib/2015-11/msg00004.html
> +
> +   Meanwhile, explicitly define these ourselves, as C99 intended.  */
> +#define __STDC_CONSTANT_MACROS
> +#define __STDC_LIMIT_MACROS
>  #include <stdint.h>
> +
>  #include <string.h>
>  #include <errno.h>
>  #include <alloca.h>
> 

FYI, I stumbled on the same problem when building for various architectures this weekend.  I
generated some toolchains by using some of the Buildroot included configurations, which use
uclibc.  I ended up defining those macros as well in CFLAGS.  So that change can help for more
configurations than just mingw.


  reply	other threads:[~2015-11-02 20:47 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-02 19:36 [PATCH 00/11] C++/MinGW patches Pedro Alves
2015-11-02 19:36 ` [PATCH 04/11] [C++/mingw] windows-nat.c casts Pedro Alves
2015-11-02 19:36 ` [PATCH 06/11] [C++/mingw] ser-tcp.c casts Pedro Alves
2015-11-02 20:40   ` Simon Marchi
2015-11-02 20:55     ` Pedro Alves
2015-11-02 21:06       ` Pedro Alves
2015-11-02 19:36 ` [PATCH 01/11] [C++/mingw] ser-mingw.c casts Pedro Alves
2015-11-02 19:36 ` [PATCH 02/11] [C++/mingw] Misc alloca casts Pedro Alves
2015-11-02 19:36 ` [PATCH 10/11] [C++/mingw] Fix windows-nat.c::xlate Pedro Alves
2015-11-02 19:36 ` [PATCH 03/11] [C++/mingw] gdb-dlfcn.c casts Pedro Alves
2015-11-02 19:36 ` [PATCH 11/11] [C++/mingw] gdbserver: gdb/host signal mixup Pedro Alves
2015-11-02 19:43 ` [PATCH 09/11] [C++/mingw] handle_output_debug_string Pedro Alves
2015-11-02 19:44 ` [PATCH 07/11] [C++/mingw] Define __STDC_CONSTANT_MACROS / __STDC_LIMIT_MACROS for stdint.h Pedro Alves
2015-11-02 20:47   ` Simon Marchi [this message]
2015-11-03 13:58     ` Simon Marchi
2015-11-03 14:07       ` Pedro Alves
2015-11-03 14:15         ` Simon Marchi
2015-11-03 15:13           ` Pedro Alves
2015-11-02 19:44 ` [PATCH 05/11] [C++/mingw] gdbserver casts Pedro Alves
2015-11-02 19:45 ` [PATCH 08/11] [C++/mingw] Simplify first chance exception handling Pedro Alves
2015-11-02 21:01   ` Simon Marchi
2015-11-02 21:09     ` Pedro Alves
2015-11-02 20:05 ` [PATCH 00/11] C++/MinGW patches Pedro Alves
2015-11-02 20:22   ` Qian Hong
2015-11-02 20:46     ` Pedro Alves
2015-11-02 21:17       ` Qian Hong
2015-11-02 23:31         ` Pedro Alves
2015-11-03  9:06           ` Qian Hong
2015-11-03 10:47       ` Qian Hong
2015-11-03 11:15         ` Qian Hong
2015-11-03 11:26           ` Pedro Alves
2015-11-03 11:41             ` Qian Hong
2015-11-03 12:11               ` Qian Hong
2015-11-03 12:34               ` Pedro Alves
2015-11-03 11:20         ` Pedro Alves
2015-11-03 16:54           ` Pedro Alves
2015-11-03 18:59             ` Qian Hong
2015-11-03 21:03             ` Qian Hong
2015-11-03 22:39               ` Pedro Alves
2015-11-09  9:53                 ` Qian Hong
2015-11-17 14:50                   ` Pedro Alves
2015-11-30 15:03                     ` Qian Hong
2015-11-30 15:48                       ` Pedro Alves
2015-11-03 12:24     ` Qian Hong
2015-11-03 12:27       ` Pedro Alves
2015-11-03 12:56         ` Qian Hong
2015-11-03 13:08           ` Pedro Alves
2015-11-03 13:23             ` Qian Hong
2015-11-03 16:52               ` Pedro Alves
2015-11-03 13:10           ` Pedro Alves
2015-11-02 21:04 ` Simon Marchi
2015-11-17 15:28   ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5637CBC9.2050404@ericsson.com \
    --to=simon.marchi@ericsson.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox