This is the mail archive of the newlib@sourceware.org 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: [PATCH] define M_PI etc. if _XOPEN_SOURCE is defined appropriately


On 01/08/2014 10:16, Corinna Vinschen wrote:
On Jul 31 14:41, Jon TURNEY wrote:
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.

You're right.  You have to #define _C99_SOURCE explicitely in your
source code to make the definitions in cdefs.h work.  This is identical
to upstream FreeBSD.

And, no, I'm not entirely sure if that's wrong or working as expected.

Maybe we should add code like this?

   #if __STDC_VERSION__ == 199901L
   #define _C99_SOURCE
   #elif __STDC_VERSION__ == 201112L
   #define _C11_SOURCE
   #endif

Anyway, please go ahead and apply your patch.

Sorry, I don't think I have commit access to newlib.


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