From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16542 invoked by alias); 3 Nov 2015 15:13:10 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 16533 invoked by uid 89); 3 Nov 2015 15:13:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 03 Nov 2015 15:13:09 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id D79DF2631; Tue, 3 Nov 2015 15:13:07 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tA3FD6P3023155; Tue, 3 Nov 2015 10:13:06 -0500 Message-ID: <5638CF02.70609@redhat.com> Date: Tue, 03 Nov 2015 15:13:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Simon Marchi , gdb-patches@sourceware.org Subject: Re: [PATCH 07/11] [C++/mingw] Define __STDC_CONSTANT_MACROS / __STDC_LIMIT_MACROS for stdint.h References: <1446492970-21432-1-git-send-email-palves@redhat.com> <1446492970-21432-8-git-send-email-palves@redhat.com> <5637CBC9.2050404@ericsson.com> <5638BD73.8000706@ericsson.com> <5638BF81.5070705@redhat.com> <5638C168.1020603@ericsson.com> In-Reply-To: <5638C168.1020603@ericsson.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2015-11/txt/msg00097.txt.bz2 On 11/03/2015 02:15 PM, Simon Marchi wrote: > On 15-11-03 09:06 AM, Pedro Alves wrote: >> Isn't this a case of "don't do that (CFLAGS), then" ? > > Maybe. I was thinking somebody might have this defined in their > development environment, but I agree it's unlikely. > As discussed on irc, -DFOO actually gives the symbol value 1, so Simon got the error because I had defined the symbols with no value, like: #define __STDC_CONSTANT_MACROS So if we define the symbols with value 1, then the error is gone. Here's the updated patch. ------- >From a710518eff022b6ab452415ab1191dc5c748dfe5 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Sun, 1 Nov 2015 17:33:36 +0000 Subject: [PATCH] [C++/mingw] Define __STDC_CONSTANT_MACROS / __STDC_LIMIT_MACROS for stdint.h 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 ." # error "This file assumes that 'int' has exactly 32 bits. Please report your platform and compiler to ." ^ 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 ." #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 * 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..548fe42 100644 --- a/gdb/common/common-defs.h +++ b/gdb/common/common-defs.h @@ -31,7 +31,23 @@ #include #include #include + +/* 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 1 +#define __STDC_LIMIT_MACROS 1 #include + #include #include #include -- 1.9.3