api.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015-2019 CNRS-UM LIRMM, CNRS-AIST JRL
3  */
4 
5 #pragma once
6 
7 // Handle portable symbol export.
8 // Defining manually which symbol should be exported is required
9 // under Windows whether MinGW or MSVC is used.
10 //
11 // The headers then have to be able to work in two different modes:
12 // - dllexport when one is building the library,
13 // - dllimport for clients using the library.
14 //
15 // On Linux, set the visibility accordingly. If C++ symbol visibility
16 // is handled by the compiler, see: http://gcc.gnu.org/wiki/Visibility
17 #if defined _WIN32 || defined __CYGWIN__
18 // On Microsoft Windows, use dllimport and dllexport to tag symbols.
19 # define MC_OBSERVERS_DLLIMPORT __declspec(dllimport)
20 # define MC_OBSERVERS_DLLEXPORT __declspec(dllexport)
21 # define MC_OBSERVERS_DLLLOCAL
22 #else
23 // On Linux, for GCC >= 4, tag symbols using GCC extension.
24 # if __GNUC__ >= 4
25 # define MC_OBSERVERS_DLLIMPORT __attribute__((visibility("default")))
26 # define MC_OBSERVERS_DLLEXPORT __attribute__((visibility("default")))
27 # define MC_OBSERVERS_DLLLOCAL __attribute__((visibility("hidden")))
28 # else
29 // Otherwise (GCC < 4 or another compiler is used), export everything.
30 # define MC_OBSERVERS_DLLIMPORT
31 # define MC_OBSERVERS_DLLEXPORT
32 # define MC_OBSERVERS_DLLLOCAL
33 # endif // __GNUC__ >= 4
34 #endif // defined _WIN32 || defined __CYGWIN__
35 
36 #ifdef MC_OBSERVERS_STATIC
37 // If one is using the library statically, get rid of
38 // extra information.
39 # define MC_OBSERVERS_DLLAPI
40 # define MC_OBSERVERS_LOCAL
41 #else
42 // Depending on whether one is building or using the
43 // library define DLLAPI to import or export.
44 # ifdef MC_CONTROL_EXPORTS
45 # define MC_OBSERVERS_DLLAPI MC_OBSERVERS_DLLEXPORT
46 # else
47 # define MC_OBSERVERS_DLLAPI MC_OBSERVERS_DLLIMPORT
48 # endif // MC_CONTROL_EXPORTS
49 # define MC_OBSERVERS_LOCAL MC_OBSERVERS_DLLLOCAL
50 #endif // MC_OBSERVERS_STATIC
51 
52 // Handle portable symbol export.
53 // Defining manually which symbol should be exported is required
54 // under Windows whether MinGW or MSVC is used.
55 //
56 // The headers then have to be able to work in two different modes:
57 // - dllexport when one is building the library,
58 // - dllimport for clients using the library.
59 //
60 // On Linux, set the visibility accordingly. If C++ symbol visibility
61 // is handled by the compiler, see: http://gcc.gnu.org/wiki/Visibility
62 #if defined _WIN32 || defined __CYGWIN__
63 // On Microsoft Windows, use dllimport and dllexport to tag symbols.
64 # define MC_OBSERVER_DLLIMPORT __declspec(dllimport)
65 # define MC_OBSERVER_DLLEXPORT __declspec(dllexport)
66 # define MC_OBSERVER_DLLLOCAL
67 #else
68 // On Linux, for GCC >= 4, tag symbols using GCC extension.
69 # if __GNUC__ >= 4
70 # define MC_OBSERVER_DLLIMPORT __attribute__((visibility("default")))
71 # define MC_OBSERVER_DLLEXPORT __attribute__((visibility("default")))
72 # define MC_OBSERVER_DLLLOCAL __attribute__((visibility("hidden")))
73 # else
74 // Otherwise (GCC < 4 or another compiler is used), export everything.
75 # define MC_OBSERVER_DLLIMPORT
76 # define MC_OBSERVER_DLLEXPORT
77 # define MC_OBSERVER_DLLLOCAL
78 # endif // __GNUC__ >= 4
79 #endif // defined _WIN32 || defined __CYGWIN__
80 
81 #ifdef MC_OBSERVER_STATIC
82 // If one is using the library statically, get rid of
83 // extra information.
84 # define MC_OBSERVER_DLLAPI
85 # define MC_OBSERVER_LOCAL
86 #else
87 // Depending on whether one is building or using the
88 // library define DLLAPI to import or export.
89 # ifdef MC_OBSERVER_EXPORTS
90 # define MC_OBSERVER_DLLAPI MC_OBSERVER_DLLEXPORT
91 # else
92 # define MC_OBSERVER_DLLAPI MC_OBSERVER_DLLIMPORT
93 # endif // MC_OBSERVER_EXPORTS
94 # define MC_OBSERVER_LOCAL MC_OBSERVER_DLLLOCAL
95 #endif // MC_OBSERVER_STATIC