public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* Feature Conditional for M_PI
@ 2020-08-31 15:10 Joel Sherrill
  2020-08-31 15:27 ` Corinna Vinschen
  0 siblings, 1 reply; 7+ messages in thread
From: Joel Sherrill @ 2020-08-31 15:10 UTC (permalink / raw)
  To: Newlib

Hi

I was porting some code from Linux to Cygwin and came across this. M_PI in
math.h is defined by POSIX as part of XSI. It does not appear to be part of
C99 or C++03.  I have this cut down to show the problem:

==========================
#include <math.h>

double pi = M_PI;
==========================

And this script to try various feature defines and compilers:

===========================
GCC=${GCC:-g++}

${GCC} -c m.c
${GCC} -D_XOPEN_SOURCE=700 -c m.c
${GCC} -D_POSIX_C_SOURCE=200809L -c m.c
${GCC} -D_XOPEN_SOURCE=700 -c -D_POSIX_C_SOURCE=200809L -c m.c
===========================

All of those compiler invocations work on Linux but the third one does not
work on Cygwin or RTEMS which use newlib.

Is the proper thing to do to add  -D_XOPEN_SOURCE=700 when compiling this
program?

Just curious if Linux is defining _XOPEN_SOURCE by default and newlib
doesn't. Not sure what's the right answer. So asking.

Thanks

--joel

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-09-01  2:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-31 15:10 Feature Conditional for M_PI Joel Sherrill
2020-08-31 15:27 ` Corinna Vinschen
2020-08-31 15:29   ` Corinna Vinschen
2020-08-31 15:50     ` Joel Sherrill
2020-08-31 20:04       ` Corinna Vinschen
2020-08-31 21:19         ` Joel Sherrill
2020-09-01  2:04           ` Yaakov Selkowitz

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).