Skip to content

Commit cadb1cb

Browse files
author
kokosxD
committed
Define math constants for Visual Studio
Like M_PI as mentioned in some examples
1 parent efa69ad commit cadb1cb

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ int main() {
2626
A more comprehensive example:
2727
```cpp
2828
#include "matplotlibcpp.h"
29-
#include <cmath>
30-
3129
namespace plt = matplotlibcpp;
3230
3331
int main()
@@ -67,9 +65,7 @@ int main()
6765

6866
Alternatively, matplotlib-cpp also supports some C++11-powered syntactic sugar:
6967
```cpp
70-
#include <cmath>
7168
#include "matplotlibcpp.h"
72-
7369
using namespace std;
7470
namespace plt = matplotlibcpp;
7571

@@ -104,8 +100,6 @@ Or some *funny-looking xkcd-styled* example:
104100
```cpp
105101
#include "matplotlibcpp.h"
106102
#include <vector>
107-
#include <cmath>
108-
109103
namespace plt = matplotlibcpp;
110104
111105
int main() {
@@ -291,4 +285,4 @@ Todo/Issues/Wishlist
291285
in "".'
292286

293287
* MacOS: `Unable to import matplotlib.pyplot`. Cause: In mac os image rendering back end of matplotlib (what-is-a-backend to render using the API of Cocoa by default). There is Qt4Agg and GTKAgg and as a back-end is not the default. Set the back end of macosx that is differ compare with other windows or linux os.
294-
Solution is described [here](https://stackoverflow.com/questions/21784641/installation-issue-with-matplotlib-python?noredirect=1&lq=1), additional information can be found there too(see links in answers).
288+
Solution is described [here](https://stackoverflow.com/questions/21784641/installation-issue-with-matplotlib-python?noredirect=1&lq=1), additional information can be found there too(see links in answers).

matplotlibcpp.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#pragma once
22

3+
// Define math constants for Visual Studio https://docs.microsoft.com/en-us/cpp/c-runtime-library/math-constants
4+
#if defined(_MSC_VER)
5+
#define _USE_MATH_DEFINES
6+
#endif
7+
38
// Python headers must be included before any system headers, since
49
// they define _POSIX_C_SOURCE
510
#include <Python.h>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy