unknown type errors cpython/object.h in simple project

21 views
Skip to first unread message

Andrew Annex

unread,
Jan 9, 2023, 2:27:21 AM1/9/23
to cython-users
I am attempting to prototype a project using cython 0.29.32 in a python 3.11 conda environment on macos 13.1, and I am running into compilation issues seemingly unrelated to my code and related to the python c headers (see below). So far my project simply uses a single function from a c library that I am passing the headers and c source files to 

I don't understand the issue and didn't see anything like it per-say, some things maybe point to xcode but I am using a conda environment, assistance is appreciated!

some examples: 

/Users/andrew/anaconda3/envs/cythondev/include/python3.11/object.h:123:8: error: unknown type name 'inline'
static inline Py_ssize_t Py_REFCNT(PyObject *ob) {
       ^
/Users/andrew/anaconda3/envs/cythondev/include/python3.11/object.h:123:25: error: expected ';' after top level declarator
static inline Py_ssize_t Py_REFCNT(PyObject *ob) {
                        ^
                        ;
/Users/andrew/anaconda3/envs/cythondev/include/python3.11/object.h:262:8: error: unknown type name 'inline'
static inline int PyObject_TypeCheck(PyObject *ob, PyTypeObject *type) {
       ^
/Users/andrew/anaconda3/envs/cythondev/include/python3.11/object.h:263:12: error: implicit declaration of function 'Py_IS_TYPE' [-Werror,-Wimplicit-function-declaration]
    return Py_IS_TYPE(ob, type) || PyType_IsSubtype(Py_TYPE(ob), type);

/Users/andrew/anaconda3/envs/cythondev/include/python3.11/cpython/object.h:72:5: error: unknown type name 'unaryfunc'; did you mean 'binaryfunc'?
    unaryfunc nb_negative;

D Woods

unread,
Jan 9, 2023, 3:53:43 AM1/9/23
to cython-users
Bit of a guess here but I think recent versions of Python now require a C99 (or maybe C11?) compiler (for inline I think). It's possibly just a compiler flag you need to turn on C99 mode.

Andrew Annex

unread,
Jan 10, 2023, 2:49:20 AM1/10/23
to cython-users
Thanks for the suggestion, I tried a few things using https://github.com/thearn/simple-cython-example as a example project and found that I probably had an issue with my xcode and xcode command line tools. After reinstalling each I was able to build with the system level clang. Although I was not able to build my own project, I had the same issues still there confusingly even though my project isn't that complicated.

That was when I started looking a bit more at my project, I had a few extra compile args I carried over from another script (like -ansi, oops) without paying attention to them, that were important for the project when I was compiling the shared library. Removing them allowed my project to build using the system level clang, but I still am having issues with the conda environment at the linking stage (see below). Ideally I'd be able to use the conda environment to keep things isolate and compatible as I start to incorporate numpy into my cython code. 

I think that my problem may be with the compilers that are available on conda-forge and from anaconda or perhaps the way I am making the environment or perhaps some other system environment leak. I made a new conda environment using  `conda create --name cythondev python=3.10 anaconda` and then separately worked out that I needed to install the c-compilers project for conda forge or clang_osx-64 for main anaconda channel. 

Either way the conda c compiler seems to be picking up some of the xcode environment as I get this error: 
"ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd' for architecture x86_64"

It looks like the macosx sdk used is somehow wrong?
Reply all
Reply to author
Forward
0 new messages