libfilezilla
Macros
visibility_helper.hpp File Reference

Helper macros for symbol visibility in shared libraries. More...

Go to the source code of this file.

Macros

#define FZ_EXPORT_PUBLIC
 Marks symbols as public to be exported.
 
#define FZ_EXPORT_PRIVATE
 Marks symbols as private, they won't be exported.
 
#define FZ_IMPORT_SHARED
 Import symbols from a shared library.
 
#define FZ_IMPORT_STATIC
 Import symbols from a static library.
 

Detailed Description

Helper macros for symbol visibility in shared libraries.

There are two main cases: Building a library and using it. For building, symbols need to be marked as export, for using it they need to be imported.

Usage example:

#include <libfilezilla/visibility_helper>
#ifdef BUILDING_LIBRARY // Provide this yourself
#define PUBLIC_SYMBOL FZ_EXPORT_PUBLIC
#define PRIVATE_SYMBOL FZ_EXPORT_PRIVATE
#else
#define PRIVATE_SYMBOL
#if USING_DLL // Provide this yourself
#define PUBLIC_SYMBOL FZ_IMPORT_SHARED
#else
#define PUBLIC_SYMBOL FZ_IMPORT_STATIC
#endif
#endif
struct PUBLIC_SYMBOL example {
void do_stuff();
void PRIVATE_SMBOL for_internal_use();
};