New submission from Sunyeop Lee: PyMemberDef from Noddy examaple: https://docs.python.org/3/extending/newtypes.html
static PyMemberDef Noddy_members[] = { {"first", T_OBJECT_EX, offsetof(Noddy, first), 0, "first name"}, {"last", T_OBJECT_EX, offsetof(Noddy, last), 0, "last name"}, {"number", T_INT, offsetof(Noddy, number), 0, "noddy number"}, {NULL} /* Sentinel */ }; When compiling the code with the PyMemberDef above with GCC, it compiles well. However, with G++, ISO C++11 complains(warns) it is deprecated to convert string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings] Should the example code be fixed, or should PyMemberDef fixed? I think PyMemberDef.name should bo const char * instead of char *. Compiled with: g++ test.cpp -I/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/include/python3.6m -L/usr/local/opt/python3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/config-3.6m-darwin -lpython3.6m -fPIC -shared Compiler versions: $ gcc -v Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 8.1.0 (clang-802.0.38) Target: x86_64-apple-darwin16.5.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin $ g++ -v Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 8.1.0 (clang-802.0.38) Target: x86_64-apple-darwin16.5.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin ---------- components: Extension Modules files: test.cpp messages: 291459 nosy: Sunyeop Lee priority: normal severity: normal status: open title: [RFC] PyMemberDef.name should be const char * type: compile error versions: Python 3.6 Added file: http://bugs.python.org/file46795/test.cpp _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30035> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com