Skip to content

Commit ed67005

Browse files
authored
Minor fix for MSVC warning CS4459 (#1374)
When using pybind11 to bind enums on MSVC and warnings (/W4) enabled, the following warning pollutes builds. This fix renames one of the occurrences. pybind11\include\pybind11\pybind11.h(1398): warning C4459: declaration of 'self' hides global declaration pybind11\include\pybind11\operators.h(41): note: see declaration of 'pybind11::detail::self'
1 parent ffd56eb commit ed67005

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

include/pybind11/pybind11.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -1389,9 +1389,9 @@ template <typename Type> class enum_ : public class_<Type> {
13891389
}
13901390
return pybind11::str("???");
13911391
});
1392-
def_property_readonly_static("__doc__", [m_entries_ptr](handle self) {
1392+
def_property_readonly_static("__doc__", [m_entries_ptr](handle self_) {
13931393
std::string docstring;
1394-
const char *tp_doc = ((PyTypeObject *) self.ptr())->tp_doc;
1394+
const char *tp_doc = ((PyTypeObject *) self_.ptr())->tp_doc;
13951395
if (tp_doc)
13961396
docstring += std::string(tp_doc) + "\n\n";
13971397
docstring += "Members:";
@@ -1404,7 +1404,7 @@ template <typename Type> class enum_ : public class_<Type> {
14041404
}
14051405
return docstring;
14061406
});
1407-
def_property_readonly_static("__members__", [m_entries_ptr](handle /* self */) {
1407+
def_property_readonly_static("__members__", [m_entries_ptr](handle /* self_ */) {
14081408
dict m;
14091409
for (const auto &kv : reinterpret_borrow<dict>(m_entries_ptr))
14101410
m[kv.first] = kv.second[int_(0)];

0 commit comments

Comments
 (0)