Skip to content

Commit 07a61aa

Browse files
authored
Fix char8_t support (#4278)
Standard library macro __cpp_lib_char8_t is only available after including standard header
1 parent d1c31e9 commit 07a61aa

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

include/pybind11/detail/common.h

+5-4
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,6 @@
205205
# endif
206206
#endif
207207

208-
#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
209-
# define PYBIND11_HAS_U8STRING
210-
#endif
211-
212208
#include <Python.h>
213209
#if PY_VERSION_HEX < 0x03060000
214210
# error "PYTHON < 3.6 IS UNSUPPORTED. pybind11 v2.9 was the last to support Python 2 and 3.5."
@@ -259,6 +255,11 @@
259255
# endif
260256
#endif
261257

258+
// Must be after including <version> or one of the other headers specified by the standard
259+
#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
260+
# define PYBIND11_HAS_U8STRING
261+
#endif
262+
262263
// #define PYBIND11_STR_LEGACY_PERMISSIVE
263264
// If DEFINED, pybind11::str can hold PyUnicodeObject or PyBytesObject
264265
// (probably surprising and never documented, but this was the

0 commit comments

Comments
 (0)