|
22 | 22 | // Additional convention: 0xD = dev |
23 | 23 | #define PYBIND11_VERSION_HEX 0x030000D1 |
24 | 24 |
|
25 | | -// Define some generic pybind11 helper macros for warning management. |
26 | | -// |
27 | | -// Note that compiler-specific push/pop pairs are baked into the |
28 | | -// PYBIND11_NAMESPACE_BEGIN/PYBIND11_NAMESPACE_END pair of macros. Therefore manual |
29 | | -// PYBIND11_WARNING_PUSH/PYBIND11_WARNING_POP are usually only needed in `#include` sections. |
30 | | -// |
31 | | -// If you find you need to suppress a warning, please try to make the suppression as local as |
32 | | -// possible using these macros. Please also be sure to push/pop with the pybind11 macros. Please |
33 | | -// only use compiler specifics if you need to check specific versions, e.g. Apple Clang vs. vanilla |
34 | | -// Clang. |
35 | | -#if defined(_MSC_VER) |
36 | | -# define PYBIND11_COMPILER_MSVC |
37 | | -# define PYBIND11_PRAGMA(...) __pragma(__VA_ARGS__) |
38 | | -# define PYBIND11_WARNING_PUSH PYBIND11_PRAGMA(warning(push)) |
39 | | -# define PYBIND11_WARNING_POP PYBIND11_PRAGMA(warning(pop)) |
40 | | -#elif defined(__INTEL_COMPILER) |
41 | | -# define PYBIND11_COMPILER_INTEL |
42 | | -# define PYBIND11_PRAGMA(...) _Pragma(#__VA_ARGS__) |
43 | | -# define PYBIND11_WARNING_PUSH PYBIND11_PRAGMA(warning push) |
44 | | -# define PYBIND11_WARNING_POP PYBIND11_PRAGMA(warning pop) |
45 | | -#elif defined(__clang__) |
46 | | -# define PYBIND11_COMPILER_CLANG |
47 | | -# define PYBIND11_PRAGMA(...) _Pragma(#__VA_ARGS__) |
48 | | -# define PYBIND11_WARNING_PUSH PYBIND11_PRAGMA(clang diagnostic push) |
49 | | -# define PYBIND11_WARNING_POP PYBIND11_PRAGMA(clang diagnostic pop) |
50 | | -#elif defined(__GNUC__) |
51 | | -# define PYBIND11_COMPILER_GCC |
52 | | -# define PYBIND11_PRAGMA(...) _Pragma(#__VA_ARGS__) |
53 | | -# define PYBIND11_WARNING_PUSH PYBIND11_PRAGMA(GCC diagnostic push) |
54 | | -# define PYBIND11_WARNING_POP PYBIND11_PRAGMA(GCC diagnostic pop) |
55 | | -#endif |
56 | | - |
57 | | -#ifdef PYBIND11_COMPILER_MSVC |
58 | | -# define PYBIND11_WARNING_DISABLE_MSVC(name) PYBIND11_PRAGMA(warning(disable : name)) |
59 | | -#else |
60 | | -# define PYBIND11_WARNING_DISABLE_MSVC(name) |
61 | | -#endif |
62 | | - |
63 | | -#ifdef PYBIND11_COMPILER_CLANG |
64 | | -# define PYBIND11_WARNING_DISABLE_CLANG(name) PYBIND11_PRAGMA(clang diagnostic ignored name) |
65 | | -#else |
66 | | -# define PYBIND11_WARNING_DISABLE_CLANG(name) |
67 | | -#endif |
68 | | - |
69 | | -#ifdef PYBIND11_COMPILER_GCC |
70 | | -# define PYBIND11_WARNING_DISABLE_GCC(name) PYBIND11_PRAGMA(GCC diagnostic ignored name) |
71 | | -#else |
72 | | -# define PYBIND11_WARNING_DISABLE_GCC(name) |
73 | | -#endif |
74 | | - |
75 | | -#ifdef PYBIND11_COMPILER_INTEL |
76 | | -# define PYBIND11_WARNING_DISABLE_INTEL(name) PYBIND11_PRAGMA(warning disable name) |
77 | | -#else |
78 | | -# define PYBIND11_WARNING_DISABLE_INTEL(name) |
79 | | -#endif |
80 | | - |
81 | | -#define PYBIND11_NAMESPACE_BEGIN(name) \ |
82 | | - namespace name { \ |
83 | | - PYBIND11_WARNING_PUSH |
84 | | - |
85 | | -#define PYBIND11_NAMESPACE_END(name) \ |
86 | | - PYBIND11_WARNING_POP \ |
87 | | - } |
88 | | - |
89 | | -// Robust support for some features and loading modules compiled against different pybind versions |
90 | | -// requires forcing hidden visibility on pybind code, so we enforce this by setting the attribute |
91 | | -// on the main `pybind11` namespace. |
92 | | -#if !defined(PYBIND11_NAMESPACE) |
93 | | -# ifdef __GNUG__ |
94 | | -# define PYBIND11_NAMESPACE pybind11 __attribute__((visibility("hidden"))) |
95 | | -# else |
96 | | -# define PYBIND11_NAMESPACE pybind11 |
97 | | -# endif |
98 | | -#endif |
| 25 | +#include "pybind11_namespace_macros.h" |
99 | 26 |
|
100 | 27 | #if !(defined(_MSC_VER) && __cplusplus == 199711L) |
101 | 28 | # if __cplusplus >= 201402L |
|
0 commit comments