Skip to content

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

@cagev

Description

@cagev

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions