Allow Sharing C++ Classes Across Modules · Issue #4561 - GitHub
Có thể bạn quan tâm
-
Uh oh!
There was an error while loading. Please reload this page.
- Notifications You must be signed in to change notification settings
- Fork 1.6k
- Star 10.6k
- Code
- Issues 1.3k
- Pull requests 175
- Actions
- Wiki
- Security 0
- Insights
Description
I have these files to reproduce the problem, mod2.pxd:
cdef void myapi() cdef cppclass myclass: void mymethod()mod2.pyx
cdef void myapi(): print("I am OK (from myapi)") cdef cppclass myclass: void mymethod(): # Using anything C is OK cdef int i = 0 i += 1 # Crash with Python var # Segmentation fault j = 0 j += 1 # Crash with Python function # Segmentation fault print("I am crashing!")mod1.pxd
cdef void myfunc()mod1.pyx
from mod2 cimport myapi, myclass cdef cppclass foo: void bar(): print("I am OK (from foo.bar)") cdef void myfunc(): print("I am OK") myapi() cdef foo f f.bar() # Stack var: Segmentation fault print("Calling myclass.mymethod...") cdef myclass t t.mymethod() # # Pointer: Segmentation fault # print("Calling myclass.mymethod...") # cdef myclass* t2 = new myclass() # t2.mymethod() cpdef test(): myfunc()Main Python programme app.py
import mod1 mod1.test()It's a segmentation fault which happens in a Cython struct myclass when using anything Python. Also in mod2, but the global function myapi is OK. From a struct method foo.bar but in the same file is also OK.
I'm using Python 3.8.2, and Cython 0.29.26
mod1 and mod2 are translated into C++ with cython -3 --cplus command, and compiled with gcc to .so files. It happened the same if using Python build tool. As suggested from https://stackoverflow.com/a/55669343/5581893 I tried to add -DCYTHON_PEP489_MULTI_PHASE_INIT=0 to all gcc commands but no help.
This situation seems strange, why are Python stuff not touch-able from mod2 (fails in struct only)?
Metadata
Metadata
Assignees
No one assignedLabels
Type
No typeProjects
No projectsMilestone
No milestoneRelationships
None yetDevelopment
No branches or pull requestsIssue actions
You can’t perform that action at this time.Từ khóa » Cython C++ Github
-
Cython/wrapping_t At Master - GitHub
-
Cython C++ Example - Gists · GitHub
-
[ENH] C++ Variant · Issue #4677 · Cython/cython - GitHub
-
Cython · GitHub Topics
-
Cython C++ Example - Gists · GitHub
-
Cython 0.16 C++ Demo - Gists · GitHub
-
A Few Quick Tutorials On Using C++ Function In Python Code With Cython
-
Cython/cython: The Most Widely Used Python To C Compiler - GitHub
-
Cython · GitHub Topics
-
Cython-wrapper · GitHub Topics
-
Molpopgen/cython_mcpp: Glue Layer Between Cython And C++11 ...
-
Add C++ "to_string()" Function To Declarations. - GitHub
-
David-cortes/cycereal: C++ Cereal Headers As An ... - GitHub
-
Cython-wrapper · GitHub Topics