This is the mail archive of the mailing list for the newlib project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ISO C99 support in <math.h> for C++98

On 22/03/16 15:42, Yaakov Selkowitz wrote:
> On 2016-03-22 09:52, Andre Vieira (lists) wrote:
>> On arm and aarch64 the libstdc++ test
>> 26_numerics/headers/cmath/ has been
>> failing with (among others) the following errors:
> [snip]
>> Since the only code my gcc-5 and trunk builds share is newlib I suspect
>> it might be caused by it. I had a look at cmath and found that the
>> macros mentioned above are undef'd if the condition
>> _GLIBCXX_USE_C99_MATH holds true. This is defined as
>> _GLIBCXX98_USE_C99_MATH if -std=gnu++98 is passed and in my latest
>> builds _GLIBCXX98_USE_C99_MATH is no longer being defined in
>> c++config.h. This define is set by gcc's configure step 'Checking for
>> ISO C99 support in <math.h> for C++98' which used to succeed but now
>> fails.
>> I did get a bit lost after locating the code to check this in
>> gcc/libstdc++/acinclude.m4 as it seems it tries to compile a file with
>> all the functions (macros in C99), that are undef'd in cmath if
>> _GLIBCXX_USE_C99_MATH, which isn't happening... So apparently during
>> configuration it seems include math.h does not define this set of
>> functions, so _GLIBCXX98_USE_C99_MATH is never defined and thus the
>> macros for these functions are never undef'ed in cmath, where all of a
>> sudden they seem to be defined.
>> Does anyone have an idea whats going on here? I wanted to try with
>> earlier commits of newlib to maybe identify what change was responsible
>> for this new behavior, but I am failing to build due to the
>> configuration scripts needing regeneration and I wasn't able to
>> regenerate them. I tried a sequence of commands that used to work in the
>> past but they no longer do :(
> We also had issues enabling C99-in-C++ on Cygwin (which is based on
> newlib), which required a few patches:
> It is on my to-do list to get this working on newlib targets once we
> have a snapshot with the new feature test macros.
Hi Yaakov,

Ok so I now know where the problem is coming from, its the fact that
_GLIBCXX98_USE_C99_MATH is defined based on the configure which uses
-std=g++98, whereas the test in libstdc++ uses -std=gnu++98. The first
ends up with a __ISO_C_VISIBLE 1990 the latter 1999 because
_POSIX_C_SOURCE is defined as 200809L for gnu++98 and undefined for c++98.

This was working before because the C99 functions would always be
included when compiling for c++ due to the || defined(__cplusplus),
adding this back would fix it, but I'm assuming you removed it for a
reason. I will look further into why this discrepancy in macros for
c++98 and gnu++98.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]