|
From: | Markus Mützel |
Subject: | [Octave-bug-tracker] [bug #61812] Math constants (e.g. M_PI) are not part of C/C++ standard |
Date: | Thu, 13 Jan 2022 09:40:25 -0500 (EST) |
User-agent: | Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36 Edg/97.0.1072.55 |
URL: <https://savannah.gnu.org/bugs/?61812> Summary: Math constants (e.g. M_PI) are not part of C/C++ standard Project: GNU Octave Submitted by: mmuetzel Submitted on: Thu 13 Jan 2022 03:40:23 PM CET Category: Interpreter Severity: 3 - Normal Priority: 5 - Normal Item Group: Build Failure Status: None Assigned to: None Originator Name: Originator Email: Open/Closed: Open Release: 7.0.90 Discussion Lock: Any Operating System: Any _______________________________________________________ Details: Math constants are not defined in standard C or C++. They are a GNU/POSIX extension. See: https://en.cppreference.com/w/cpp/header/cmath At least on Windows, compilation of headers that use any of those math constants fails if a "strict" dialect is selected (e.g. `-std=c++11`). One header that uses e.g. M_PI is `liboctave/util/oct-cmplx.h`. C++20 defines `std::numbers::pi` in `<numbers>`: https://en.cppreference.com/w/cpp/numeric/constants On Windows, the older C math constants can be forced to be defined by `<cmath>` with `#define _USE_MATH_DEFINES` prior to including this header. That also works if a "strict" C++ dialect is selected. Should we do that? Or avoid using these non-standard constants in headers entirely? Which alternatives are there? _______________________________________________________ Reply to this item at: <https://savannah.gnu.org/bugs/?61812> _______________________________________________ Message sent via Savannah https://savannah.gnu.org/
[Prev in Thread] | Current Thread | [Next in Thread] |