Skip to content

Commit e2661de

Browse files
committed
Copy clang 17 compatibility fixes from PR pybind#4762 to a separate PR.
1 parent f3e0602 commit e2661de

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

include/pybind11/cast.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1377,7 +1377,15 @@ inline namespace literals {
13771377
/** \rst
13781378
String literal version of `arg`
13791379
\endrst */
1380-
constexpr arg operator"" _a(const char *name, size_t) { return arg(name); }
1380+
constexpr arg
1381+
#if !defined(__clang__) && defined(__GNUC__) && __GNUC__ < 5
1382+
operator"" _a // gcc 4.8.5 insists on having a space (hard error).
1383+
#else
1384+
operator""_a // clang 17 generates a deprecation warning if there is a space.
1385+
#endif
1386+
(const char *name, size_t) {
1387+
return arg(name);
1388+
}
13811389
} // namespace literals
13821390

13831391
PYBIND11_NAMESPACE_BEGIN(detail)

include/pybind11/pytypes.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1612,7 +1612,15 @@ inline namespace literals {
16121612
/** \rst
16131613
String literal version of `str`
16141614
\endrst */
1615-
inline str operator"" _s(const char *s, size_t size) { return {s, size}; }
1615+
inline str
1616+
#if !defined(__clang__) && defined(__GNUC__) && __GNUC__ < 5
1617+
operator"" _s // gcc 4.8.5 insists on having a space (hard error).
1618+
#else
1619+
operator""_s // clang 17 generates a deprecation warning if there is a space.
1620+
#endif
1621+
(const char *s, size_t size) {
1622+
return {s, size};
1623+
}
16161624
} // namespace literals
16171625

16181626
/// \addtogroup pytypes

0 commit comments

Comments
 (0)