portability.h
Go to the documentation of this file.
1 /**************************************************************************/ /**
2  * @brief Library portability helper definitions.
3  * @file
4  ******************************************************************************/
5 
6 #pragma once
7 
8 // References:
9 // - https://gcc.gnu.org/wiki/Visibility.
10 // - https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/port_def.inc
11 #if defined(_WIN32) || defined(_MSC_VER) || defined(__CYGWIN__)
12  #ifdef BUILDING_DLL
13  #ifdef __GNUC__
14  #define P1_EXPORT __attribute__ ((dllexport))
15  #else
16  #define P1_EXPORT __declspec(dllexport)
17  #endif
18  #else
19  #ifdef __GNUC__
20  #define P1_EXPORT __attribute__ ((dllimport))
21  #else
22  #define P1_EXPORT __declspec(dllimport)
23  #endif
24  #endif
25  #define P1_HIDDEN
26 #else
27  #if __GNUC__ >= 4
28  #define P1_EXPORT __attribute__ ((visibility ("default")))
29  #define P1_HIDDEN __attribute__ ((visibility ("hidden")))
30  #else
31  #define P1_EXPORT
32  #define P1_HIDDEN
33  #endif
34 #endif