[PATCH] define M_PI etc. if _XOPEN_SOURCE is defined appropriately

Jon TURNEY jon.turney@dronecode.org.uk
Thu Jul 31 13:41:00 GMT 2014

On 30/07/2014 15:19, Corinna Vinschen wrote:
> On Jul 30 15:12, Jon TURNEY wrote:
>> On 30/07/2014 14:54, Jon TURNEY wrote:
>>> math.h only defines M_PI and similar constants if __STRICT_ANSI__ is not
>>> defined.
>>> SUSv2 specifies that math.h should define some of these constants [1].
>>> Attached is a patch to also define these constants if _XOPEN_SOURCE is
>>> defined appropriately.
>> So bad :-(
>> This patch doesn't correctly handle the case where _XOPEN_SOURCE is defined
>> as the empty string.  Amended patch attached.
> You can workaround that by using the definition of __XSI_VISIBLE
> from <sys/cdefs.h>.  It's always defined and non-empty.

Yes, that seems a much better way of doing things.

However, in my testing, __XSI_VISIBLE seems to be defined by line 704 in 
cdefs.h with just -std=c99, which doesn't seem right.

More information about the Newlib mailing list