From 374e3b54c011c7b99f71957c019283b24ced5fc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Mon, 18 Nov 2019 21:56:22 +0100 Subject: [PATCH] plugins: example plugin: Make all functions invisible except for the explicitly exported ones * Add target parameters to compile all symbols invisible to the outside by default. * Edit FUNC_DECL() macro to set attribute that exports the function --- .../output-renderers/external-renderer-interfaces.h | 12 +++++++++--- plugins/plugin-example/CMakeLists.txt | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/gds-render/output-renderers/external-renderer-interfaces.h b/include/gds-render/output-renderers/external-renderer-interfaces.h index 509d029..028d248 100644 --- a/include/gds-render/output-renderers/external-renderer-interfaces.h +++ b/include/gds-render/output-renderers/external-renderer-interfaces.h @@ -13,6 +13,11 @@ * @{ */ +/** + * @brief This define is used to export a function from a shared object + */ +#define EXPORT_FUNC __attribute__((visibility("default"))) + /** * @brief Function name expected to be found in external library for rendering. * @@ -37,14 +42,15 @@ * * The pure presence of this symbol name causes forking. The content of this variable is don't care. * @note Use this if you mess with the internal structures of gds-render - * */ #define EXTERNAL_LIBRARY_FORK_REQUEST exported_fork_request /** - * @brief Define for declaring the exported functions + * @brief Define for declaring the exported functions. + * + * This not only helps with the declaration but also makes the symbols visible, so they can be called form outside the library */ -#define FUNC_DECL(FUNC) FUNC +#define FUNC_DECL(FUNC) EXPORT_FUNC FUNC /** @} */ diff --git a/plugins/plugin-example/CMakeLists.txt b/plugins/plugin-example/CMakeLists.txt index 6018e7b..40637e9 100644 --- a/plugins/plugin-example/CMakeLists.txt +++ b/plugins/plugin-example/CMakeLists.txt @@ -10,3 +10,5 @@ link_libraries(${PYTHON_LDFLAGS} version) add_library(${PROJECT_NAME} SHARED EXCLUDE_FROM_ALL ${SOURCES}) add_dependencies(${PROJECT_NAME} version) +set_target_properties(${PROJECT_NAME} PROPERTIES C_VISIBILITY_PRESET hidden) +set_target_properties(${PROJECT_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden)