bug-gnulib
[Top][All Lists]
Advanced

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

isnan function conflicts with C++ standard library declarations


From: Martin Storsjö
Subject: isnan function conflicts with C++ standard library declarations
Date: Tue, 27 Aug 2019 23:21:30 +0300 (EEST)
User-agent: Alpine 2.20 (DEB 67 2015-01-07)

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

reply via email to

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