bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to avoid fdopen redefinition?


From: Bruno Haible
Subject: Re: How to avoid fdopen redefinition?
Date: Mon, 01 Mar 2021 17:46:02 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-203-generic; KDE/5.18.0; x86_64; ; )

Hi Gavin,

> When using a stdin.h from gnulib with Perl's extension headers (e.g.
> XSUB.h), under MinGW there can be compiler warnings due to
> redefinition of an fdopen symbol. This was reported here (point 1):
> 
> https://lists.gnu.org/archive/html/bug-texinfo/2021-02/msg00152.html
> 
> We don't use fdopen in the program so it would be better if we didn't
> have to interact with this part of Gnulib. Is there any way of turning
> this off?
> 
> The relevant part of stdin.in.h is the following:
> 
> #elif @GNULIB_MDA_FDOPEN@
> /* On native Windows, map 'fdopen' to '_fdopen', so that -loldnames is not
>    required.  In C++ with GNULIB_NAMESPACE, avoid differences between
>    platforms by defining GNULIB_NAMESPACE::fdopen always.  */
> # if defined _WIN32 && !defined __CYGWIN__
> #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
> #   undef fdopen
> #   define fdopen _fdopen
> #  endif
> _GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode));
> # else
> _GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode));
> # endif
> _GL_CXXALIASWARN (fdopen);
> #endif
> 
> Is there any way of turning this off?

Yes: In your configure.ac, after the invocation of gl_INIT, add an assignment

  GNULIB_MDA_FDOPEN=0

> https://lists.gnu.org/archive/html/bug-gnulib/2020-12/msg00220.html
> 
> It says in that message,
> 
>     Conditionalize each of the Windows oldnames workarounds through a
> GNULIB_MDA_<func> symbol.

Yes, that's the commit where GNULIB_MDA_FDOPEN was introduced.

> I don't know what MDA means

MDA means "Microsoft deprecated alias". 'fdopen' is POSIX, and after using
POSIX as the base for some of their APIs for years, they decided to deprecate
these functions that are in POSIX but not in ISO C++. (They don't care
about ISO C.)

> https://lists.gnu.org/archive/html/bug-texinfo/2021-02/msg00152.html

That message also says
  "MS-Windows doesn't support LC_MESSAGES in its
   setlocale API, I guess that's what triggers the problem."

If you request the gnulib module 'setlocale', you will get not only
LC_MESSAGES, but also a setlocale() override that works with it.

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]