@@ -2141,7 +2141,8 @@ template <class T> function get_overload(const T *this_ptr, const char *name) {
2141
2141
return tinfo ? get_type_overload (this_ptr, tinfo, name) : function ();
2142
2142
}
2143
2143
2144
- #define PYBIND11_OVERLOAD_INT (ret_type, cname, name, ...) { \
2144
+ #define PYBIND11_OVERLOAD_INT (ret_type, cname, name, ...) \
2145
+ do { \
2145
2146
pybind11::gil_scoped_acquire gil; \
2146
2147
pybind11::function overload = pybind11::get_overload (static_cast <const cname *>(this ), name); \
2147
2148
if (overload) { \
@@ -2152,7 +2153,7 @@ template <class T> function get_overload(const T *this_ptr, const char *name) {
2152
2153
} \
2153
2154
else return pybind11::detail::cast_safe<ret_type>(std::move (o)); \
2154
2155
} \
2155
- }
2156
+ } while ( false )
2156
2157
2157
2158
/* * \rst
2158
2159
Macro to populate the virtual method in the trampoline class. This macro tries to look up a method named 'fn'
@@ -2172,16 +2173,20 @@ template <class T> function get_overload(const T *this_ptr, const char *name) {
2172
2173
}
2173
2174
\endrst */
2174
2175
#define PYBIND11_OVERLOAD_NAME (ret_type, cname, name, fn, ...) \
2175
- PYBIND11_OVERLOAD_INT (PYBIND11_TYPE (ret_type), PYBIND11_TYPE (cname), name, __VA_ARGS__) \
2176
- return cname::fn (__VA_ARGS__)
2176
+ do { \
2177
+ PYBIND11_OVERLOAD_INT (PYBIND11_TYPE (ret_type), PYBIND11_TYPE (cname), name, __VA_ARGS__); \
2178
+ return cname::fn (__VA_ARGS__); \
2179
+ } while (false )
2177
2180
2178
2181
/* * \rst
2179
2182
Macro for pure virtual functions, this function is identical to :c:macro:`PYBIND11_OVERLOAD_NAME`, except that it
2180
2183
throws if no overload can be found.
2181
2184
\endrst */
2182
2185
#define PYBIND11_OVERLOAD_PURE_NAME (ret_type, cname, name, fn, ...) \
2183
- PYBIND11_OVERLOAD_INT (PYBIND11_TYPE (ret_type), PYBIND11_TYPE (cname), name, __VA_ARGS__) \
2184
- pybind11::pybind11_fail (" Tried to call pure virtual function \" " PYBIND11_STRINGIFY (cname) " ::" name " \" " );
2186
+ do { \
2187
+ PYBIND11_OVERLOAD_INT (PYBIND11_TYPE (ret_type), PYBIND11_TYPE (cname), name, __VA_ARGS__); \
2188
+ pybind11::pybind11_fail (" Tried to call pure virtual function \" " PYBIND11_STRINGIFY (cname) " ::" name " \" " ); \
2189
+ } while (false )
2185
2190
2186
2191
/* * \rst
2187
2192
Macro to populate the virtual method in the trampoline class. This macro tries to look up the method
0 commit comments