api.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015-2020 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_TVM_DLLIMPORT __declspec(dllimport)
20 # define MC_TVM_DLLEXPORT __declspec(dllexport)
21 # define MC_TVM_DLLLOCAL
22 #else
23 // On Linux, for GCC >= 4, tag symbols using GCC extension.
24 # if __GNUC__ >= 4
25 # define MC_TVM_DLLIMPORT __attribute__((visibility("default")))
26 # define MC_TVM_DLLEXPORT __attribute__((visibility("default")))
27 # define MC_TVM_DLLLOCAL __attribute__((visibility("hidden")))
28 # else
29 // Otherwise (GCC < 4 or another compiler is used), export everything.
30 # define MC_TVM_DLLIMPORT
31 # define MC_TVM_DLLEXPORT
32 # define MC_TVM_DLLLOCAL
33 # endif // __GNUC__ >= 4
34 #endif // defined _WIN32 || defined __CYGWIN__
35 
36 #ifdef MC_TVM_STATIC
37 // If one is using the library statically, get rid of
38 // extra information.
39 # define MC_TVM_DLLAPI
40 # define MC_TVM_LOCAL
41 #else
42 // Depending on whether one is building or using the
43 // library define DLLAPI to import or export.
44 # ifdef MC_TVM_EXPORTS
45 # define MC_TVM_DLLAPI MC_TVM_DLLEXPORT
46 # else
47 # define MC_TVM_DLLAPI MC_TVM_DLLIMPORT
48 # endif // MC_TVM_EXPORTS
49 # define MC_TVM_LOCAL MC_TVM_DLLLOCAL
50 #endif // MC_TVM_STATIC