Skip to content

Commit 88a8d74

Browse files
authored
Add warning about usage of embind without C++17 (#25424)
See #24850
1 parent cfd8d71 commit 88a8d74

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ See docs/process.md for more on how version tagging works.
2020

2121
4.0.16 (in development)
2222
-----------------------
23+
- A warning was added about usage of embind without C++17 or above. (#25424)
2324
- The minimum supported versions of Node, Chrome and Firefox were bumped
2425
enabling the removal of the `globalThis` polyfill and universally enabling
2526
mutable globals: (#25375, #25385)

system/include/emscripten/bind.h

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

88
#pragma once
99

10-
#if __cplusplus < 201103L
11-
#error Including <emscripten/bind.h> requires building with -std=c++11 or newer!
12-
#endif
13-
1410
#include <cassert>
1511
#include <cstddef>
1612
#include <functional>

system/include/emscripten/val.h

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

88
#pragma once
99

10-
#if __cplusplus < 201103L
11-
#error Including <emscripten/val.h> requires building with -std=c++11 or newer!
12-
#endif
13-
1410
#include <cassert>
1511
#include <array>
1612
#include <climits>

system/include/emscripten/wire.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
#pragma once
99

1010
#if __cplusplus < 201103L
11-
#error Including <emscripten/wire.h> requires building with -std=c++11 or newer!
11+
#error "embind requires -std=c++11 or newer"
12+
#endif
13+
14+
#if __cplusplus < 201703L
15+
#warning "embind is likely moving to c++17 (https://github.com/emscripten-core/emscripten/issues/24850)"
1216
#endif
1317

1418
// A value moving between JavaScript and C++ has three representations:

test/test_other.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3328,7 +3328,7 @@ def test_embind_no_raw_pointers(self, filename):
33283328
# With no arguments we are effectively testing c++17 since it is the default.
33293329
'': [],
33303330
# Ensure embind compiles under C++11 which is the miniumum supported version.
3331-
'cxx11': ['-std=c++11'],
3331+
'cxx11': ['-std=c++11', '-Wno-#warnings'],
33323332
'o1': ['-O1'],
33333333
'o2': ['-O2'],
33343334
'o2_mem_growth': ['-O2', '-sALLOW_MEMORY_GROWTH', test_file('embind/isMemoryGrowthEnabled=true.cpp')],
@@ -3377,6 +3377,14 @@ def test_embind(self, *extra_args):
33773377
output = self.run_js(js_file)
33783378
self.assertNotContained('FAIL', output)
33793379

3380+
def test_embind_cxx11_warning(self):
3381+
err = self.run_process([EMXX, '-c', '-std=c++11', test_file('embind/test_unsigned.cpp')], stderr=PIPE).stderr
3382+
self.assertContained('#warning "embind is likely moving to c++17', err)
3383+
3384+
def test_embind_cxx03(self):
3385+
err = self.expect_fail([EMXX, '-c', '-std=c++03', test_file('embind/test_unsigned.cpp')])
3386+
self.assertContained('#error "embind requires -std=c++11 or newer"', err)
3387+
33803388
@requires_node
33813389
def test_embind_finalization(self):
33823390
self.run_process(

0 commit comments

Comments
 (0)