I am not sure if the following is flawed but this pattern has worked for Python2 but is now breaking when changing to Python3 compilation.
# foo.h
``` c
#ifndef FOO_H
#define FOO_H
namespace foo {
class Foo {
public:
Foo() {};
~Foo() {};
};
}
#endif
```
# mwe_test.pxd
``` python
cdef extern from "foo.h" namespace "foo":
cdef cppclass Foo:
Foo() except +
cdef class CyFoo:
cdef Foo *foo_cpp
@staticmethod
cdef create(Foo *f)
```
# mwe_test.pyx
``` python
import cython
from mwe_test cimport *
cdef class CyFoo:
@staticmethod
cdef create(Foo *f):
cdef CyFoo f_wrap = CyFoo()
f_wrap.foo_cpp = f
return f_wrap
```
When running within a python2 environment, no errors in generating `cxx` files.
``` sh
cython --version # Cython version 0.29.21
cython --cplus -2 --output-file /tmp/mwe/mwe_test.cxx -I /tmp/mwe/src/mwe /tmp/mwe/src/mwe/mwe_test.pyx
```
When running the same thing from python3, I get an error:
``` sh
cython --version # Cython version 0.29.23
cython --cplus -3 --output-file /tmp/mwe/mwe_test.cxx -I /tmp/mwe/src/mwe /tmp/mwe/src/mwe/mwe_test.pyx
# Error compiling Cython file:
# src/mwe/mwe_test.pxd:8:16: C method 'create' is declared but not defined
```
Thanks for any tips