Skip to content

Commit 3d85ff5

Browse files
committed
feat: unify export macro settings and add symbol visibility for Unix platforms
1 parent aeae6a6 commit 3d85ff5

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

wsjtx_bridge/CMakeLists.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,15 @@ target_link_libraries(wsjtx_bridge PRIVATE wsjtx_lib)
2020
# 设置C++标准
2121
set_property(TARGET wsjtx_bridge PROPERTY CXX_STANDARD 17)
2222

23-
# Windows: 设置导出宏
24-
if(WIN32)
25-
target_compile_definitions(wsjtx_bridge PRIVATE WSJTX_BRIDGE_EXPORTS)
23+
# 设置导出宏(全平台)
24+
target_compile_definitions(wsjtx_bridge PRIVATE WSJTX_BRIDGE_EXPORTS)
25+
26+
# 设置符号可见性(Unix平台)
27+
if(NOT WIN32)
28+
set_target_properties(wsjtx_bridge PROPERTIES
29+
CXX_VISIBILITY_PRESET default
30+
VISIBILITY_INLINES_HIDDEN OFF
31+
)
2632
endif()
2733

2834
# 包含wsjtx_lib头文件

wsjtx_bridge/wsjtx_bridge.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77
#define WSJTX_BRIDGE_API __declspec(dllimport)
88
#endif
99
#else
10-
#define WSJTX_BRIDGE_API
10+
// Unix (Linux/macOS): 使用 GCC/Clang visibility 属性
11+
#ifdef WSJTX_BRIDGE_EXPORTS
12+
#define WSJTX_BRIDGE_API __attribute__((visibility("default")))
13+
#else
14+
#define WSJTX_BRIDGE_API
15+
#endif
1116
#endif
1217

1318
#ifdef __cplusplus

0 commit comments

Comments
 (0)