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] | |
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.
$ cat m_pi_test.c
#include <math.h>
int main()
{
double d = M_PI;
}
before patch:
$ gcc m_pi_test.c
$ gcc -std=c99 m_pi_test.c
m_pi_test.c: In function âmainâ:
m_pi_test.c:5:14: error: âM_PIâ undeclared (first use in this function)
$ gcc -std=c99 m_pi_test.c -D_XOPEN_SOURCE=500
m_pi_test.c: In function âmainâ:
m_pi_test.c:5:14: error: âM_PIâ undeclared (first use in this function)
after patch:
$ gcc m_pi_test.c
$ gcc -std=c99 m_pi_test.c
m_pi_test.c: In function âmainâ:
m_pi_test.c:5:14: error: âM_PIâ undeclared (first use in this function)
$ gcc -std=c99 m_pi_test.c -D_XOPEN_SOURCE=500
2014-07-30 Jon TURNEY <jon.turney@dronecode.org.uk>
* libc/include/math.h: Also define M_PI etc. if _XOPEN_SOURCE is
defined appropriately.
[1] http://pubs.opengroup.org/onlinepubs/007908799/xsh/math.h.html
Attachment:
math.h.patch
Description: Text document
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |