Community
Participate
Working Groups
The C client library currently controls which functions/symbols are exported on Windows using the DLLExport macro. There is no similar control on Linux, but there should be. The "Version script" page at http://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_node/ld_25.html describes how to control which functions are exported and almost more importantly, how to version functions. I can provide more details if needed, it's quite easy really. The gcc option to add in the linker script is "-Wl,--version-script=linker.version"
Agreed. Up to now I didn't know it was possible, or how to do it. Thanks
Great call Roger, thank you! let's get this into the Makefile and respective source files. As we move towards a formal release these kinds of details are vital.
Assigning to MQTT-C
So, as per this document: https://www.gnu.org/software/gnulib/manual/html_node/Exported-Symbols-of-Shared-Libraries.html the preferred method is "The programmer specifies a “hidden” attribute for all files that make up the shared library, and an “exported” attribute for those symbols in these files that shall be exported. This is perfect: It burdens the maintainer only for exported API, not for library-internal API. And it keeps the annotations in the source code." implemented by adding -fvisibility=hidden to the compile options, and __attribute__ ((visibility ("default"))) to each definition to be exported. This method is very similar to the Windows method already used, so we already usable tags in the source code. I propose using this method. The only downside is that the -fvisibility compile option is not supported in gcc earlier than v4.
Fixed as I suggested above.
Could I suggest the following then: #if defined(__GNUC__) && __GNUC__ >= 4 # define DLLExport __attribute__ ((visibility ("default"))) #else # define DLLExport #endif