Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] in 3.0.0x, embed multi modules cause errors : redefinition of ‘PyObject* __PYX_WARN_IF_INIT_CALLED(PyObject*)’ #4308

Closed
cagev opened this issue Jul 23, 2021 · 1 comment · Fixed by #4309

Comments

@cagev
Copy link

cagev commented Jul 23, 2021

Describe the bug
in embed mode, I created three cython modules, "network, engine , market" , after compiled, include the head files in main
#include "engine/engine.h"
#include "engine/market.h"
#include "engine/network.h"
all the generated head files defined same function: __PYX_WARN_IF_INIT_CALLED will cause redefinition errors

To Reproduce
In file included from /home/arthur/work/aule/src/main.cpp:11:
/home/arthur/work/aule/./engine/market.h:46:18: error: redefinition of ‘PyObject* __PYX_WARN_IF_INIT_CALLED(PyObject*)’
46 | static PyObject* __PYX_WARN_IF_INIT_CALLED(PyObject* res) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/arthur/work/aule/src/main.cpp:10:
/home/arthur/work/aule/./engine/engine.h:75:18: note: ‘PyObject* __PYX_WARN_IF_INIT_CALLED(PyObject*)’ previously defined here
75 | static PyObject* __PYX_WARN_IF_INIT_CALLED(PyObject* res) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/arthur/work/aule/src/main.cpp:12:
/home/arthur/work/aule/./engine/network.h:46:18: error: redefinition of ‘PyObject* __PYX_WARN_IF_INIT_CALLED(PyObject*)’
46 | static PyObject* __PYX_WARN_IF_INIT_CALLED(PyObject* res) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/arthur/work/aule/src/main.cpp:10:
/home/arthur/work/aule/./engine/engine.h:75:18: note: ‘PyObject* __PYX_WARN_IF_INIT_CALLED(PyObject*)’ previously defined here
75 | static PyObject* __PYX_WARN_IF_INIT_CALLED(PyObject* res) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/xengine.dir/build.make:193: CMakeFiles/xengine.dir/src/main.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:324: CMakeFiles/xengine.dir/all] Error 2

Expected behavior
should the generated head file use different names?

Environment (please complete the following information):

  • OS: Ubuntu 20.04
  • Python version 3.9.6
  • Cython version 3.0.0x
  • gcc version (Ubuntu 10.3.0-1ubuntu1~20.04) 10.3.0

Additional context
I set up a demo here , https://github.com/cagev/cythonembeddemo

@da-woods
Copy link
Contributor

I suspect the function definition of __PYX_WARN_IF_INIT_CALLED should either be in a little include-guard. Or it should be renamed __PYX_WARN_IF_<module name>_INIT_CALLED. Either would work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants