[Cython] cython --cplus --embed generates invalid code

Stefan Behnel stefan_ml at behnel.de
Mon Dec 1 08:28:58 CET 2014


Michael Enßlin schrieb am 30.11.2014 um 16:14:
> on my system, --embed does not work with --cplus.
> 
> How to reproduce: Any valid pyx file works:
> 
> $ rm -f test.pyx; touch test.pyx
> $ cython --embed --cplus test.pyx
> $ g++ -c test.cpp -I/usr/include/python3.4m
> test.cpp: In function ‘wchar_t* __Pyx_char2wchar(char*)’:
> test.cpp:945:41: error: invalid conversion from ‘void*’ to ‘wchar_t*’
> [-fpermissive]
>      res = malloc(argsize*sizeof(wchar_t));
> $ clang++ -c test.cpp -I/usr/include/python3.4m
> test.cpp:945:9: error: assigning to 'wchar_t *' from incompatible type
> 'void *'
>     res = malloc(argsize*sizeof(wchar_t));
> 
> 
> The issue can easily be fixed by manually casting the malloc result to
> (wchar_t *).

Thanks. IIRC, that's actually code copied from CPython (where it is never
compiled as C++).

https://github.com/cython/cython/commit/d65a7c176003a84aa5640fdb7c4134dd915454c7

Stefan



More information about the cython-devel mailing list