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-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,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 B733E1F5AF for ; Mon, 29 Mar 2021 08:23:48 +0000 (UTC) Received: from localhost ([::1]:53998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lQnBb-0006yY-L0 for normalperson@yhbt.net; Mon, 29 Mar 2021 04:23:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36232) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQnBW-0006yM-7w for bug-gnulib@gnu.org; Mon, 29 Mar 2021 04:23:43 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:39816) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lQnBV-0003Pb-W8 for bug-gnulib@gnu.org; Mon, 29 Mar 2021 04:23:42 -0400 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4774 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1lQnBV-0005n0-CC for bug-gnulib@gnu.org; Mon, 29 Mar 2021 04:23:41 -0400 Date: Mon, 29 Mar 2021 11:23:50 +0300 Message-Id: <83czvimkq1.fsf@gnu.org> From: Eli Zaretskii To: bug-gnulib@gnu.org Subject: swab wrapper fails mingw.org's MinGW compilation of GDB 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: , Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" 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)} The suggested fix is as follows (__MINGW32_VERSION is defined by mingw.org's MinGW, but not by MinGW64): --- unistd.h~ 2021-03-29 09:15:08.782625000 +0300 +++ unistd.h 2021-03-29 10:19:46.485750000 +0300 @@ -2540,7 +2540,11 @@ _GL_WARN_ON_USE (sleep, "sleep is unport # undef swab # define swab _swab # endif +# if defined __MINGW32_VERSION +_GL_CXXALIAS_MDA (swab, void, (const char *from, char *to, size_t n)); +# else _GL_CXXALIAS_MDA (swab, void, (char *from, char *to, int n)); +# endif # else _GL_CXXALIAS_SYS (swab, void, (const void *from, void *to, ssize_t n)); # endif