From: "Martin Storsjö" <martin@martin.st>
To: bug-gnulib@gnu.org
Subject: isnan function conflicts with C++ standard library declarations
Date: Tue, 27 Aug 2019 23:21:30 +0300 (EEST) [thread overview]
Message-ID: <alpine.DEB.2.20.1908272314290.6969@cone.martin.st> (raw)
[-- Attachment #1: Type: text/plain, Size: 1581 bytes --]
Hi,
When the isnan function is enabled in gnulib, the added bits in math.h
break if included in C++ translation units.
A minimal reproducion example is available at
https://martin.st/temp/gnulib-isnan-repro-0.0.0.tar.gz (preconfigured and
directly buildable) and
https://martin.st/temp/gnulib-isnan-repro-source.tar.gz (original source,
requires running gnulib-tool and autoreconf).
The error manifests both with GCC/libstdc++ and Clang/libc++, with error
messages like these:
In file included from myprog.cpp:2:0:
lib/math.h: In function ‘int isnan(float)’:
lib/math.h:2829:1: error: ‘int isnan(float)’ conflicts with a previous declaration
_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan)
^
In file included from /usr/include/c++/7/math.h:36:0,
from lib/math.h:27,
from myprog.cpp:2:
/usr/include/c++/7/cmath:618:3: note: previous declaration ‘constexpr bool std::isnan(float)’
isnan(float __x)
^~~~~
Or this:
In file included from myprog.cpp:2:
lib/math.h:2829:36: error: 'isnan' is missing exception specification 'throw()'
_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan)
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/math.h:533:1: note:
previous declaration is here
isnan(float __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); }
^
This issue can crop up e.g. when trying to build gettext for mingw (which
has got the gnulib isnan function bundled, even if it isn't used).
// Martin
next reply other threads:[~2019-08-27 20:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-27 20:21 Martin Storsjö [this message]
2019-08-28 8:46 ` isnan function conflicts with C++ standard library declarations Bruno Haible
2019-08-28 10:22 ` Martin Storsjö
2019-08-28 16:13 ` Bruno Haible
2019-08-28 19:51 ` Martin Storsjö
2019-08-29 18:55 ` Martin Storsjö
2019-08-29 22:02 ` Bruno Haible
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.20.1908272314290.6969@cone.martin.st \
--to=martin@martin.st \
--cc=bug-gnulib@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).