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_TASKS_ROS_DLLIMPORT __declspec(dllimport)
20 # define MC_TASKS_ROS_DLLEXPORT __declspec(dllexport)
21 # define MC_TASKS_ROS_DLLLOCAL
22 #else
23 // On Linux, for GCC >= 4, tag symbols using GCC extension.
24 # if __GNUC__ >= 4
25 # define MC_TASKS_ROS_DLLIMPORT __attribute__((visibility("default")))
26 # define MC_TASKS_ROS_DLLEXPORT __attribute__((visibility("default")))
27 # define MC_TASKS_ROS_DLLLOCAL __attribute__((visibility("hidden")))
28 # else
29 // Otherwise (GCC < 4 or another compiler is used), export everything.
30 # define MC_TASKS_ROS_DLLIMPORT
31 # define MC_TASKS_ROS_DLLEXPORT
32 # define MC_TASKS_ROS_DLLLOCAL
33 # endif // __GNUC__ >= 4
34 #endif // defined _WIN32 || defined __CYGWIN__
35 
36 #ifdef MC_TASKS_ROS_STATIC
37 // If one is using the library statically, get rid of
38 // extra information.
39 # define MC_TASKS_ROS_DLLAPI
40 # define MC_TASKS_ROS_LOCAL
41 #else
42 // Depending on whether one is building or using the
43 // library define DLLAPI to import or export.
44 # ifdef MC_TASKS_ROS_EXPORTS
45 # define MC_TASKS_ROS_DLLAPI MC_TASKS_ROS_DLLEXPORT
46 # else
47 # define MC_TASKS_ROS_DLLAPI MC_TASKS_ROS_DLLIMPORT
48 # endif // MC_TASKS_ROS_EXPORTS
49 # define MC_TASKS_ROS_LOCAL MC_TASKS_ROS_DLLLOCAL
50 #endif // MC_TASKS_ROS_STATIC