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 #include <cstdint>
9 
10 // References:
11 // - https://gcc.gnu.org/wiki/Visibility.
12 // - https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/port_def.inc
13 #if defined(_WIN32) || defined(_MSC_VER) || defined(__CYGWIN__)
14 # ifdef BUILDING_DLL
15 # ifdef __GNUC__
16 # define P1_EXPORT __attribute__((dllexport))
17 # else
18 # define P1_EXPORT __declspec(dllexport)
19 # endif
20 # else
21 # ifdef __GNUC__
22 # define P1_EXPORT __attribute__((dllimport))
23 # else
24 # define P1_EXPORT __declspec(dllimport)
25 # endif
26 # endif
27 # define P1_HIDDEN
28 #else
29 # if __GNUC__ >= 4
30 # define P1_EXPORT __attribute__((visibility("default")))
31 # define P1_HIDDEN __attribute__((visibility("hidden")))
32 # else
33 # define P1_EXPORT
34 # define P1_HIDDEN
35 # endif
36 #endif
37 
38 // ssize_t is a POSIX extension and is not supported on Windows.
39 #if defined(_WIN32)
40 typedef int32_t p1_ssize_t;
41 #elif defined(_MSC_VER)
42 typedef int64_t p1_ssize_t;
43 #else
44 # include <sys/types.h> // For ssize_t
45 typedef ssize_t p1_ssize_t;
46 #endif
ssize_t p1_ssize_t
Definition: portability.h:45