C ++ 17 compatibility with Python 2.7

The most recent version of python 2.7 (2.7.13) includes a header unicodeobject.hthat uses a keyword register. I understand that C ++ 17 removed this keyword. When compiling with this header using C ++ 17, many inconveniences are triggered, including:

/opt/anaconda/include/python2.7/unicodeobject.h:534:24: warning: ISO C++1z does not allow ‘register’ storage class specifier [-Wregister]
 register PyObject *obj,     /* Object */
                    ^~~
/opt/anaconda/include/python2.7/unicodeobject.h:553:24: warning: ISO C++1z does not allow ‘register’ storage class specifier [-Wregister]
 register PyObject *obj      /* Object */
                    ^~~
/opt/anaconda/include/python2.7/unicodeobject.h:575:29: warning: ISO C++1z does not allow ‘register’ storage class specifier [-Wregister]
 register const wchar_t *w,  /* wchar_t buffer */
                         ^
/opt/anaconda/include/python2.7/unicodeobject.h:593:23: warning: ISO C++1z does not allow ‘register’ storage class specifier [-Wregister]
 register wchar_t *w,        /* wchar_t buffer */

However, I can still compile and run python extensions, despite these warnings. Can I continue to do this? Is there a way (besides explicitly ignoring warnings) to resolve these messages, such as upgrading to another version 2.7 (although, as already mentioned, the newest version still uses the keyword register)?

+4
source share
1

register Python 3 , , , Python 3 (Python 2 ).

.

  • (, ), register ( ). , , , .
  • CPython C, ++, C register, , , , C, C (, gcc) ++. ( , ++, , , ).
  • . , 4 register, , .
  • . , -Wno-register , :

    #pragma GCC diagnostic push
    #pragma GCC diagnostic ignored "-Wregister"`
    #include <unicodeobject.h> // or whatever header includes unicodeobject.h
    #pragma GCC diagnostic pop
    

    , register , . GCC, , .

+4

Source: https://habr.com/ru/post/1695872/


All Articles