Commit 85b131a7 authored by Bastien Brunnenstein's avatar Bastien Brunnenstein Committed by Wouter van Oortmerssen

Replace the non standard M_PI with a constant (#4528)

parent 0e8a2185
......@@ -18,12 +18,6 @@
#include <list>
#include <iostream>
#ifdef _WIN32
#if !defined(_USE_MATH_DEFINES)
#define _USE_MATH_DEFINES // For M_PI.
#endif // !defined(_USE_MATH_DEFINES)
#endif // _WIN32
#include <math.h>
#include "flatbuffers/idl.h"
......@@ -31,6 +25,8 @@
namespace flatbuffers {
const double kPi = 3.14159265358979323846;
const char *const kTypeNames[] = {
#define FLATBUFFERS_TD(ENUM, IDLTYPE, \
CTYPE, JTYPE, GTYPE, NTYPE, PTYPE) \
......@@ -1272,8 +1268,8 @@ CheckedError Parser::ParseSingleValue(Value &e) {
auto x = strtod(e.constant.c_str(), nullptr); \
e.constant = NumToString(op); \
}
FLATBUFFERS_FN_DOUBLE("deg", x / M_PI * 180);
FLATBUFFERS_FN_DOUBLE("rad", x * M_PI / 180);
FLATBUFFERS_FN_DOUBLE("deg", x / kPi * 180);
FLATBUFFERS_FN_DOUBLE("rad", x * kPi / 180);
FLATBUFFERS_FN_DOUBLE("sin", sin(x));
FLATBUFFERS_FN_DOUBLE("cos", cos(x));
FLATBUFFERS_FN_DOUBLE("tan", tan(x));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment