Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 046376d

Browse files
committedMay 25, 2024
acos and constexpr with clang++
Removed `-lm` requirement for `acos` on MacOS. Added a comment about `acos` not being constexpr in some cmath implementations (clang++ for example).
1 parent 366822f commit 046376d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed
 

‎02-variables-scopes-and-namespaces.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,9 @@ In fact, `constexpr` expressions can be complex with recent compilers, as long a
468468
#include <cmath>
469469
using namespace std;
470470

471+
// Note: currently, not all compilers mark `acos` as a
472+
// constexpr function in cmath. The following line might
473+
// not compile with `clang++` for example.
471474
constexpr double PI1 = acos(-1.0);
472475
constexpr double PI2 = 22.0 / 7.0;
473476

@@ -480,7 +483,7 @@ int main() {
480483
}
481484
```
482485
483-
(Hint: this program is the first to require an additional header to `<print>`; you may need to add `-lm` to the compile command under Linux/MacOS in order to link in the math library containing the `acos()` function.)
486+
(Hint: this program is the first to require an additional header to `<print>`; you may need to add `-lm` to the compile command under Linux in order to link in the math library containing the `acos()` function.)
484487
485488
**Experiment**
486489

0 commit comments

Comments
 (0)
Please sign in to comment.