From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 383 invoked by alias); 8 May 2017 15:25:41 -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 131004 invoked by uid 89); 8 May 2017 15:25:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=unavailable version=3.3.2 spammy= X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (208.118.235.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 08 May 2017 15:25:39 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d7kXZ-0003sO-A5 for gdb-patches@sourceware.org; Mon, 08 May 2017 11:25:40 -0400 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:53424) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d7kXZ-0003sJ-6p for gdb-patches@sourceware.org; Mon, 08 May 2017 11:25:37 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:1571 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1d7kXY-0001J2-Be; Mon, 08 May 2017 11:25:36 -0400 Date: Mon, 08 May 2017 15:25:00 -0000 Message-Id: <83k25rcqw2.fsf@gnu.org> From: Eli Zaretskii To: gcc-patches@gcc.gnu.org CC: gdb-patches@sourceware.org Subject: MinGW compilation warnings in libiberty's include/environ.h Reply-to: Eli Zaretskii X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-IsSubscribed: yes X-SW-Source: 2017-05/txt/msg00188.txt.bz2 When compiling libiberty (as part of GDB) with MinGW on MS-Windows, I see the following warning: gcc -c -DHAVE_CONFIG_H -O2 -gdwarf-4 -g3 -D__USE_MINGW_ACCESS -I. -I./../include -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -pedantic -D_GNU_SOURCE ./setenv.c -o setenv.o In file included from ./setenv.c:64:0: ./../include/environ.h:30:1: warning: function declaration isn't a prototype [-Wstrict-prototypes] extern char **environ; ^ This was already reported 4 years ago, here: https://gcc.gnu.org/ml/gcc-patches/2013-03/msg00471.html and was solved back then. But it looks like the offending code was copied to include/environ.h without the fix, and the warning is thus back. The problem is with this code in environ.h: #ifndef HAVE_ENVIRON_DECL # ifdef __APPLE__ # include # define environ (*_NSGetEnviron ()) # else extern char **environ; # endif # define HAVE_ENVIRON_DECL #endif which causes the MinGW compiler to see the declaration of environ, whereas MinGW's stdlib.h has this: #ifdef __MSVCRT__ # define _environ (*__p__environ()) extern _CRTIMP __cdecl __MINGW_NOTHROW char ***__p__environ(void); # define _wenviron (*__p__wenviron()) extern _CRTIMP __cdecl __MINGW_NOTHROW wchar_t ***__p__wenviron(void); #else /* ! __MSVCRT__ */ # ifndef __DECLSPEC_SUPPORTED # define _environ (*_imp___environ_dll) extern char ***_imp___environ_dll; # else /* __DECLSPEC_SUPPORTED */ # define _environ _environ_dll __MINGW_IMPORT char ** _environ_dll; # endif /* __DECLSPEC_SUPPORTED */ #endif /* ! __MSVCRT__ */ #define environ _environ Can this be fixed again, please? The solution, as back then, is this: #ifndef HAVE_ENVIRON_DECL # ifdef __APPLE__ # include # define environ (*_NSGetEnviron ()) # else # ifndef environ extern char **environ; # endif # endif # define HAVE_ENVIRON_DECL #endif Thanks.