@@ -2127,7 +2127,8 @@ template <class T> function get_overload(const T *this_ptr, const char *name) {
2127
2127
return tinfo ? get_type_overload (this_ptr, tinfo, name) : function ();
2128
2128
}
2129
2129
2130
- #define PYBIND11_OVERLOAD_INT (ret_type, cname, name, ...) { \
2130
+ #define PYBIND11_OVERLOAD_INT (ret_type, cname, name, ...) \
2131
+ do { \
2131
2132
pybind11::gil_scoped_acquire gil; \
2132
2133
pybind11::function overload = pybind11::get_overload (static_cast <const cname *>(this ), name); \
2133
2134
if (overload) { \
@@ -2138,7 +2139,7 @@ template <class T> function get_overload(const T *this_ptr, const char *name) {
2138
2139
} \
2139
2140
else return pybind11::detail::cast_safe<ret_type>(std::move (o)); \
2140
2141
} \
2141
- }
2142
+ } while ( false )
2142
2143
2143
2144
/* * \rst
2144
2145
Macro to populate the virtual method in the trampoline class. This macro tries to look up a method named 'fn'
@@ -2158,16 +2159,20 @@ template <class T> function get_overload(const T *this_ptr, const char *name) {
2158
2159
}
2159
2160
\endrst */
2160
2161
#define PYBIND11_OVERLOAD_NAME (ret_type, cname, name, fn, ...) \
2161
- PYBIND11_OVERLOAD_INT (PYBIND11_TYPE (ret_type), PYBIND11_TYPE (cname), name, __VA_ARGS__) \
2162
- return cname::fn (__VA_ARGS__)
2162
+ do { \
2163
+ PYBIND11_OVERLOAD_INT (PYBIND11_TYPE (ret_type), PYBIND11_TYPE (cname), name, __VA_ARGS__); \
2164
+ return cname::fn (__VA_ARGS__); \
2165
+ } while (false )
2163
2166
2164
2167
/* * \rst
2165
2168
Macro for pure virtual functions, this function is identical to :c:macro:`PYBIND11_OVERLOAD_NAME`, except that it
2166
2169
throws if no overload can be found.
2167
2170
\endrst */
2168
2171
#define PYBIND11_OVERLOAD_PURE_NAME (ret_type, cname, name, fn, ...) \
2169
- PYBIND11_OVERLOAD_INT (PYBIND11_TYPE (ret_type), PYBIND11_TYPE (cname), name, __VA_ARGS__) \
2170
- pybind11::pybind11_fail (" Tried to call pure virtual function \" " PYBIND11_STRINGIFY (cname) " ::" name " \" " );
2172
+ do { \
2173
+ PYBIND11_OVERLOAD_INT (PYBIND11_TYPE (ret_type), PYBIND11_TYPE (cname), name, __VA_ARGS__); \
2174
+ pybind11::pybind11_fail (" Tried to call pure virtual function \" " PYBIND11_STRINGIFY (cname) " ::" name " \" " ); \
2175
+ } while (false )
2171
2176
2172
2177
/* * \rst
2173
2178
Macro to populate the virtual method in the trampoline class. This macro tries to look up the method
0 commit comments