diff --git a/CMakeLists.txt b/CMakeLists.txt index eb8cf36..f3552a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,8 @@ add_executable(rtc_plugins include/MRTCEnginePlatForm.hpp util/RTCContext.cpp rtc_plugins.cpp - util/RTCContext.cpp) + util/RTCContext.cpp + util/numpyConfig.h) add_library(rtc_plugins_lib SHARED rtc_plugins.cpp util/RTCContext.cpp) diff --git a/rtc_plugins.cpp b/rtc_plugins.cpp index 741cc49..e0b5edf 100644 --- a/rtc_plugins.cpp +++ b/rtc_plugins.cpp @@ -1,10 +1,6 @@ // rtc_plugins.cpp -#define PY_ARRAY_UNIQUE_SYMBOL MY_PROJECT_ARRAY_API // 必须与头文件一致 -#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION - -#include -#include +#include "./util/numpyConfig.h" #include "./util/RTCContext.h" diff --git a/util/RTCContext.h b/util/RTCContext.h index 855b4eb..0a12cc2 100644 --- a/util/RTCContext.h +++ b/util/RTCContext.h @@ -1,9 +1,7 @@ // RTCContext.h #pragma once -// 必须在所有include之前定义 -#define PY_ARRAY_UNIQUE_SYMBOL MY_PROJECT_ARRAY_API // 必须是项目唯一名称 -#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION +#include "numpyConfig.h" #include "IMRTCEngine.hpp" #include "MRTCEngineDefine.hpp" diff --git a/util/numpyConfig.h b/util/numpyConfig.h new file mode 100644 index 0000000..7e7f1d6 --- /dev/null +++ b/util/numpyConfig.h @@ -0,0 +1,13 @@ +// numpy_config.h +#pragma once + +// 使用更独特的项目前缀(建议:__) +#define PY_ARRAY_UNIQUE_SYMBOL RTC_PLUGINS_7A3B_ARRAY_API +#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION + +// 确保只被包含一次 +#ifndef NUMPY_CONFIG_INCLUDED +#define NUMPY_CONFIG_INCLUDED +#include +#include +#endif \ No newline at end of file