This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Sunyeop Lee
Recipients Sunyeop Lee
Date 2017-04-11.04:34:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1491885285.14.0.166738608305.issue30035@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2017-04-11 04:34:45Sunyeop Leesetrecipients: + Sunyeop Lee
2017-04-11 04:34:45Sunyeop Leesetmessageid: <1491885285.14.0.166738608305.issue30035@psf.upfronthosting.co.za>
2017-04-11 04:34:44Sunyeop Leelinkissue30035 messages
2017-04-11 04:34:43Sunyeop Leecreate