Skip to content

Commit b68607e

Browse files
committed
Splitting out include/pybind11/detail/pragma_warning_block.h
1 parent 40d77f7 commit b68607e

File tree

5 files changed

+39
-32
lines changed

5 files changed

+39
-32
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ set(PYBIND11_HEADERS
105105
include/pybind11/detail/descr.h
106106
include/pybind11/detail/init.h
107107
include/pybind11/detail/internals.h
108+
include/pybind11/detail/pragma_warning_block.h
108109
include/pybind11/detail/type_caster_base.h
109110
include/pybind11/detail/typeid.h
110111
include/pybind11/attr.h

include/pybind11/detail/common.h

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,38 +13,6 @@
1313
#define PYBIND11_VERSION_MINOR 6
1414
#define PYBIND11_VERSION_PATCH 3.dev1
1515

16-
#if defined(__INTEL_COMPILER)
17-
# pragma warning push
18-
# pragma warning disable 68 // integer conversion resulted in a change of sign
19-
# pragma warning disable 186 // pointless comparison of unsigned integer with zero
20-
# pragma warning disable 878 // incompatible exception specifications
21-
# pragma warning disable 1334 // the "template" keyword used for syntactic disambiguation may only be used within a template
22-
# pragma warning disable 1682 // implicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
23-
# pragma warning disable 1786 // function "strdup" was declared deprecated
24-
# pragma warning disable 1875 // offsetof applied to non-POD (Plain Old Data) types is nonstandard
25-
# pragma warning disable 2196 // warning #2196: routine is both "inline" and "noinline"
26-
#elif defined(_MSC_VER)
27-
# pragma warning(push)
28-
# pragma warning(disable: 4100) // warning C4100: Unreferenced formal parameter
29-
# pragma warning(disable: 4127) // warning C4127: Conditional expression is constant
30-
# pragma warning(disable: 4512) // warning C4512: Assignment operator was implicitly defined as deleted
31-
# pragma warning(disable: 4800) // warning C4800: 'int': forcing value to bool 'true' or 'false' (performance warning)
32-
# pragma warning(disable: 4996) // warning C4996: The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name
33-
# pragma warning(disable: 4702) // warning C4702: unreachable code
34-
# pragma warning(disable: 4522) // warning C4522: multiple assignment operators specified
35-
# pragma warning(disable: 4505) // warning C4505: 'PySlice_GetIndicesEx': unreferenced local function has been removed (PyPy only)
36-
#elif defined(__GNUG__) && !defined(__clang__)
37-
# pragma GCC diagnostic push
38-
# pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
39-
# pragma GCC diagnostic ignored "-Wunused-but-set-variable"
40-
# pragma GCC diagnostic ignored "-Wmissing-field-initializers"
41-
# pragma GCC diagnostic ignored "-Wstrict-aliasing"
42-
# pragma GCC diagnostic ignored "-Wattributes"
43-
# if __GNUC__ >= 7
44-
# pragma GCC diagnostic ignored "-Wnoexcept-type"
45-
# endif
46-
#endif
47-
4816
#define PYBIND11_NAMESPACE_BEGIN(name) namespace name {
4917
#define PYBIND11_NAMESPACE_END(name) }
5018

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#pragma once
2+
3+
#if defined(__INTEL_COMPILER)
4+
# pragma warning push
5+
# pragma warning disable 68 // integer conversion resulted in a change of sign
6+
# pragma warning disable 186 // pointless comparison of unsigned integer with zero
7+
# pragma warning disable 878 // incompatible exception specifications
8+
# pragma warning disable 1334 // the "template" keyword used for syntactic disambiguation may only be used within a template
9+
# pragma warning disable 1682 // implicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
10+
# pragma warning disable 1786 // function "strdup" was declared deprecated
11+
# pragma warning disable 1875 // offsetof applied to non-POD (Plain Old Data) types is nonstandard
12+
# pragma warning disable 2196 // warning #2196: routine is both "inline" and "noinline"
13+
#elif defined(_MSC_VER)
14+
# pragma warning(push)
15+
# pragma warning(disable: 4100) // warning C4100: Unreferenced formal parameter
16+
# pragma warning(disable: 4127) // warning C4127: Conditional expression is constant
17+
# pragma warning(disable: 4512) // warning C4512: Assignment operator was implicitly defined as deleted
18+
# pragma warning(disable: 4800) // warning C4800: 'int': forcing value to bool 'true' or 'false' (performance warning)
19+
# pragma warning(disable: 4996) // warning C4996: The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name
20+
# pragma warning(disable: 4702) // warning C4702: unreachable code
21+
# pragma warning(disable: 4522) // warning C4522: multiple assignment operators specified
22+
# pragma warning(disable: 4505) // warning C4505: 'PySlice_GetIndicesEx': unreferenced local function has been removed (PyPy only)
23+
#elif defined(__GNUG__) && !defined(__clang__)
24+
# pragma GCC diagnostic push
25+
# pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
26+
# pragma GCC diagnostic ignored "-Wunused-but-set-variable"
27+
# pragma GCC diagnostic ignored "-Wmissing-field-initializers"
28+
# pragma GCC diagnostic ignored "-Wstrict-aliasing"
29+
# pragma GCC diagnostic ignored "-Wattributes"
30+
# if __GNUC__ >= 7
31+
# pragma GCC diagnostic ignored "-Wnoexcept-type"
32+
# endif
33+
#endif

include/pybind11/pybind11.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010

1111
#pragma once
1212

13+
// Legacy pragma warning block moved to separate file, to enable iwyu cleanup of newly developed
14+
// code, without having to open up this can of worms. #HelpAppreciated cleaning this up.
15+
#include "detail/pragma_warning_block.h"
16+
1317
#include "attr.h"
1418
#include "gil.h"
1519
#include "options.h"

tests/extra_python_package/test_files.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"include/pybind11/detail/descr.h",
4343
"include/pybind11/detail/init.h",
4444
"include/pybind11/detail/internals.h",
45+
"include/pybind11/detail/pragma_warning_block.h",
4546
"include/pybind11/detail/type_caster_base.h",
4647
"include/pybind11/detail/typeid.h",
4748
}

0 commit comments

Comments
 (0)