From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 285441F8C6 for ; Sun, 20 Jun 2021 15:22:58 +0000 (UTC) Received: from localhost ([::1]:51652 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luzHk-0001XV-Tc for normalperson@yhbt.net; Sun, 20 Jun 2021 11:22:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51118) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luzHi-0001XN-D1 for bug-gnulib@gnu.org; Sun, 20 Jun 2021 11:22:54 -0400 Received: from mo4-p00-ob.smtp.rzone.de ([85.215.255.22]:21489) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luzHf-0004TU-Pj; Sun, 20 Jun 2021 11:22:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1624202568; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=qh80xVDJ5MRHU0T3Z5pG1VUFmsObPxI6fxIR5tMenZw=; b=R2Vhz5tyRXRUPYGpzZMAKzM6oFD+mfG2IMkMRHFHh/KFKQOWG51dwxXBWenAcsQRT5 cKeDAN/XLgyOjqJJYDO81/2T3rQwM4c0/2uu1c35HqYHnm1ROD/+NkxP89xHg4B10WM+ ro6SHAVhgqa93/oCBzglAhCovFhPaZPsUe5feuXWb3vyT2TWwfRHaczStZoxd+LvW+BY 5uI30GRv7tWWZmqQWLTqDPEj/44pEciS0qqolo7/oiCU63XjH89VzlxMyBMXqkoSqCyJ vSTG/1d8JA1Rl1u8zhnp491lhIp14G3VMlc0cLX/MU5p3jrrvsnKr5ClezR1qwv7i6HC 9vTw== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOGKf9yfs=" X-RZG-CLASS-ID: mo00 Received: from bruno.haible.de by smtp.strato.de (RZmta 47.27.3 DYNA|AUTH) with ESMTPSA id 401b97x5KFMm93K (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve X9_62_prime256v1 with 256 ECDH bits, eq. 3072 bits RSA)) (Client did not present a certificate); Sun, 20 Jun 2021 17:22:48 +0200 (CEST) From: Bruno Haible To: bug-gnulib@gnu.org Subject: Re: swab wrapper fails mingw.org's MinGW compilation of GDB Date: Sun, 20 Jun 2021 17:22:47 +0200 Message-ID: <4157125.b07XYjAfJy@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-210-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <83czvimkq1.fsf@gnu.org> References: <83czvimkq1.fsf@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Received-SPF: none client-ip=85.215.255.22; envelope-from=bruno@clisp.org; helo=mo4-p00-ob.smtp.rzone.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eli Zaretskii Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" Eli Zaretskii wrote in : > The following snippet from Gnulib's unistd.h causes a compilation > error when building the current development version of GDB 11: > > #if @GNULIB_MDA_SWAB@ > /* On native Windows, map 'swab' to '_swab', so that -loldnames is not > required. In C++ with GNULIB_NAMESPACE, avoid differences between > platforms by defining GNULIB_NAMESPACE::creat always. */ > # if defined _WIN32 && !defined __CYGWIN__ > # if !(defined __cplusplus && defined GNULIB_NAMESPACE) > # undef swab > # define swab _swab > # endif > _GL_CXXALIAS_MDA (swab, void, (char *from, char *to, int n)); > # else > _GL_CXXALIAS_SYS (swab, void, (const void *from, void *to, ssize_t n)); > # endif > _GL_CXXALIASWARN (swab); > #endif > > The problem is that mingw.org's MinGW uses a slightly different > prototype of _swab: > > _CRTIMP __cdecl __MINGW_NOTHROW void _swab (const char *, char *, size_t); > > So the difference between the prototypes causes this compilation error > in C++ programs: > > CXX unittests/string_view-selftests.o > In file included from ./../gdbsupport/common-defs.h:86, > from ./defs.h:28, > from unittests/string_view-selftests.c:26: > ./../gnulib/import/unistd.h: In member function 'gnulib::_gl_swab_wrapper::operator gnulib::_gl_swab_wrapper::type() const': > ./../gnulib/import/unistd.h:2543:1: error: invalid conversion from 'void (__attribute__((cdecl)) *)(const char*, char*, size_t)' {aka 'void (__attribute__((cdecl)) *)(const char*, char*, unsigned int)'} to 'gnulib::_gl_swab_wrapper::type' {aka 'void (*)(char*, char*, int)'} [-fpermissive] > 2543 | _GL_CXXALIAS_MDA (swab, void, (char *from, char *to, int n)); > | ^~~~~~~~~~~~~~~~ > | | > | void (__attribute__((cdecl)) *)(const char*, char*, size_t) {aka void (__attribute__((cdecl)) *)(const char*, char*, unsigned int)} Thanks for the report. A similar problem also exists on Solaris and HP-UX. The patch below should fix it. Tested on Solaris with CC and g++. > The suggested fix is as follows (__MINGW32_VERSION is defined by > mingw.org's MinGW, but not by MinGW64): It is good to know how to distinguish older mingw from mingw64; thanks for this info. But here we don't need to make the distinction, since we have a _GL_CXXALIAS_MDA_CAST macro for these situations. 2021-06-20 Bruno Haible unistd: Avoid compilation error in C++ mode on Solaris, HP-UX, mingw. Reported by Eli Zaretskii in . * lib/unistd.in.h (swab): Consider different declarations on Solaris, HP-UX, and old mingw. diff --git a/lib/unistd.in.h b/lib/unistd.in.h index d4d4ba7..73c882f 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -2034,9 +2034,17 @@ _GL_WARN_ON_USE (sleep, "sleep is unportable - " # undef swab # define swab _swab # endif -_GL_CXXALIAS_MDA (swab, void, (char *from, char *to, int n)); -# else +/* Need to cast, because in old mingw the arguments are + (const char *from, char *to, size_t n). */ +_GL_CXXALIAS_MDA_CAST (swab, void, (char *from, char *to, int n)); +# else +# if defined __hpux /* HP-UX */ +_GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, int n)); +# elif defined __sun && !defined _XPG4 /* Solaris */ +_GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, ssize_t n)); +# else _GL_CXXALIAS_SYS (swab, void, (const void *from, void *to, ssize_t n)); +# endif # endif _GL_CXXALIASWARN (swab); #endif