Skip to content

Commit 43f390a

Browse files
Add note that VS2017 requires /permissive- to build in C++17 mode (#2431)
* Add note that VS2017 requires /permissive- to build in C++17 mode * ci: test C++17 on MSVC 2017 * ci: args1/2, use args to override max cxx Co-authored-by: Henry Schreiner <[email protected]>
1 parent b3d8fec commit 43f390a

File tree

2 files changed

+25
-29
lines changed

2 files changed

+25
-29
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ jobs:
1616
matrix:
1717
runs-on: [ubuntu-latest, windows-latest, macos-latest]
1818
arch: [x64]
19-
max-cxx-std: [17]
2019
python:
2120
- 2.7
2221
- 3.5
@@ -28,56 +27,47 @@ jobs:
2827
- runs-on: ubuntu-latest
2928
python: 3.6
3029
arch: x64
31-
max-cxx-std: 17
32-
args: "-DPYBIND11_FINDPYTHON=ON"
33-
- runs-on: macos-latest
34-
python: 3.7
35-
arch: x64
36-
max-cxx-std: 17
37-
args: "-DPYBIND11_FINDPYTHON=ON"
30+
args: >
31+
-DPYBIND11_FINDPYTHON=ON
3832
- runs-on: windows-2016
3933
python: 3.7
4034
arch: x86
41-
max-cxx-std: 14
35+
args2: >
36+
-DCMAKE_CXX_FLAGS="/permissive- /EHsc /GR"
4237
- runs-on: windows-latest
4338
python: 3.6
4439
arch: x64
45-
max-cxx-std: 17
46-
args: "-DPYBIND11_FINDPYTHON=ON"
40+
args: >
41+
-DPYBIND11_FINDPYTHON=ON
4742
- runs-on: windows-latest
4843
python: 3.7
4944
arch: x64
50-
max-cxx-std: 17
5145

5246
- runs-on: ubuntu-latest
5347
python: 3.9-dev
5448
arch: x64
55-
max-cxx-std: 17
5649
- runs-on: macos-latest
5750
python: 3.9-dev
5851
arch: x64
59-
max-cxx-std: 17
52+
args: >
53+
-DPYBIND11_FINDPYTHON=ON
6054
6155
exclude:
6256
# Currently 32bit only, and we build 64bit
6357
- runs-on: windows-latest
6458
python: pypy2
6559
arch: x64
66-
max-cxx-std: 17
6760
- runs-on: windows-latest
6861
python: pypy3
6962
arch: x64
70-
max-cxx-std: 17
7163

7264
# Currently broken on embed_test
7365
- runs-on: windows-latest
7466
python: 3.8
7567
arch: x64
76-
max-cxx-std: 17
7768
- runs-on: windows-latest
7869
python: 3.9-dev
7970
arch: x64
80-
max-cxx-std: 17
8171

8272

8373
name: "🐍 ${{ matrix.python }} • ${{ matrix.runs-on }} • ${{ matrix.arch }} ${{ matrix.args }}"
@@ -92,8 +82,7 @@ jobs:
9282
python-version: ${{ matrix.python }}
9383
architecture: ${{ matrix.arch }}
9484

95-
- name: Setup Boost
96-
if: runner.os != 'macOS'
85+
- name: Setup Boost (Windows / Linux latest)
9786
run: echo "::set-env name=BOOST_ROOT::$BOOST_ROOT_1_72_0"
9887

9988
- name: Update CMake
@@ -113,8 +102,7 @@ jobs:
113102
- name: Prepare env
114103
run: python -m pip install -r tests/requirements.txt --prefer-binary
115104

116-
- name: Configure C++11 ${{ matrix.args }}
117-
shell: bash
105+
- name: Configure C++11 ${{ matrix.args1 }}
118106
run: >
119107
cmake -S . -B .
120108
-DPYBIND11_WERROR=ON
@@ -138,26 +126,26 @@ jobs:
138126
- name: Clean directory
139127
run: git clean -fdx
140128

141-
- name: Configure C++${{ matrix.max-cxx-std }} ${{ matrix.args }}
142-
shell: bash
129+
- name: Configure ${{ matrix.args2 }}
143130
run: >
144131
cmake -S . -B build2
145132
-DPYBIND11_WERROR=ON
146133
-DDOWNLOAD_CATCH=ON
147134
-DDOWNLOAD_EIGEN=ON
148-
-DCMAKE_CXX_STANDARD=${{ matrix.max-cxx-std }}
135+
-DCMAKE_CXX_STANDARD=17
149136
${{ matrix.args }}
137+
${{ matrix.args2 }}
150138
151-
- name: Build C++${{ matrix.max-cxx-std }}
139+
- name: Build
152140
run: cmake --build build2 -j 2
153141

154-
- name: Python tests C++${{ matrix.max-cxx-std }}
142+
- name: Python tests
155143
run: cmake --build build2 --target pytest
156144

157-
- name: C++${{ matrix.max-cxx-std }} tests
145+
- name: C++ tests
158146
run: cmake --build build2 --target cpptest
159147

160-
- name: Interface test C++${{ matrix.max-cxx-std }}
148+
- name: Interface test
161149
run: cmake --build build2 --target test_cmake_build
162150

163151
clang:

docs/basics.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ Windows
3535
On Windows, only **Visual Studio 2015** and newer are supported since pybind11 relies
3636
on various C++11 language features that break older versions of Visual Studio.
3737

38+
.. Note::
39+
40+
To use the C++17 in Visual Studio 2017 (MSVC 14.1), pybind11 requires the flag
41+
``/permissive-`` to be passed to the compiler `to enforce standard conformance`_. When
42+
building with Visual Studio 2019, this is not strictly necessary, but still adviced.
43+
44+
.. _`to enforce standard conformance`: https://docs.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance?view=vs-2017
45+
3846
To compile and run the tests:
3947

4048
.. code-block:: batch

0 commit comments

Comments
 (0)