Skip to content

Commit bc3cd8a

Browse files
authored
Splitting out include/pybind11/detail/pragma_warning_block.h (#2988)
* Splitting out include/pybind11/detail/pragma_warning_block.h * Always including pragma_warning_block.h before common.h (resolved 8 CI failures).
1 parent 2256f2a commit bc3cd8a

10 files changed

+49
-32
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ set(PYBIND11_HEADERS
106106
include/pybind11/detail/dynamic_raw_ptr_cast_if_possible.h
107107
include/pybind11/detail/init.h
108108
include/pybind11/detail/internals.h
109+
include/pybind11/detail/pragma_warning_block.h
109110
include/pybind11/detail/smart_holder_poc.h
110111
include/pybind11/detail/smart_holder_sfinae_hooks_only.h
111112
include/pybind11/detail/smart_holder_type_casters.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

include/pybind11/detail/dynamic_raw_ptr_cast_if_possible.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#pragma once
66

7+
#include "pragma_warning_block.h"
8+
79
#include "common.h"
810

911
#include <type_traits>
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/detail/smart_holder_sfinae_hooks_only.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#pragma once
66

7+
#include "pragma_warning_block.h"
8+
79
#include "common.h"
810

911
#include <type_traits>

include/pybind11/detail/smart_holder_type_casters.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#pragma once
66

7+
#include "pragma_warning_block.h"
8+
79
#include "../gil.h"
810
#include "../pytypes.h"
911
#include "../trampoline_self_life_support.h"

include/pybind11/pybind11.h

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

1212
#pragma once
1313

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

include/pybind11/smart_holder.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#pragma once
66

7+
#include "detail/pragma_warning_block.h"
8+
79
#include "detail/common.h"
810
#include "detail/smart_holder_type_casters.h"
911
#include "pybind11.h"

include/pybind11/trampoline_self_life_support.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#pragma once
66

7+
#include "detail/pragma_warning_block.h"
8+
79
#include "detail/common.h"
810
#include "detail/smart_holder_poc.h"
911
#include "detail/type_caster_base.h"

tests/extra_python_package/test_files.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"include/pybind11/detail/dynamic_raw_ptr_cast_if_possible.h",
4646
"include/pybind11/detail/init.h",
4747
"include/pybind11/detail/internals.h",
48+
"include/pybind11/detail/pragma_warning_block.h",
4849
"include/pybind11/detail/smart_holder_poc.h",
4950
"include/pybind11/detail/smart_holder_sfinae_hooks_only.h",
5051
"include/pybind11/detail/smart_holder_type_casters.h",

0 commit comments

Comments
 (0)