rclcpp_components  master
Package containing tools for dynamically loadable components
visibility_control.hpp
Go to the documentation of this file.
1 // Copyright 2020 Open Source Robotics Foundation, Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 /* This header must be included by all rclcpp headers which declare symbols
16  * which are defined in the rclcpp library. When not building the rclcpp
17  * library, i.e. when using the headers in other package's code, the contents
18  * of this header change the visibility of certain symbols which the rclcpp
19  * library cannot have, but the consuming code must have inorder to link.
20  */
21 
22 #ifndef RCLCPP_COMPONENTS__VISIBILITY_CONTROL_HPP_
23 #define RCLCPP_COMPONENTS__VISIBILITY_CONTROL_HPP_
24 
25 // This logic was borrowed (then namespaced) from the examples on the gcc wiki:
26 // https://gcc.gnu.org/wiki/Visibility
27 
28 #if defined _WIN32 || defined __CYGWIN__
29  #ifdef __GNUC__
30  #define RCLCPP_COMPONENTS_EXPORT __attribute__ ((dllexport))
31  #define RCLCPP_COMPONENTS_IMPORT __attribute__ ((dllimport))
32  #else
33  #define RCLCPP_COMPONENTS_EXPORT __declspec(dllexport)
34  #define RCLCPP_COMPONENTS_IMPORT __declspec(dllimport)
35  #endif
36  #ifdef RCLCPP_COMPONENTS_BUILDING_LIBRARY
37  #define RCLCPP_COMPONENTS_PUBLIC RCLCPP_COMPONENTS_EXPORT
38  #else
39  #define RCLCPP_COMPONENTS_PUBLIC RCLCPP_COMPONENTS_IMPORT
40  #endif
41  #define RCLCPP_COMPONENTS_PUBLIC_TYPE RCLCPP_COMPONENTS_PUBLIC
42  #define RCLCPP_COMPONENTS_LOCAL
43 #else
44  #define RCLCPP_COMPONENTS_EXPORT __attribute__ ((visibility("default")))
45  #define RCLCPP_COMPONENTS_IMPORT
46  #if __GNUC__ >= 4
47  #define RCLCPP_COMPONENTS_PUBLIC __attribute__ ((visibility("default")))
48  #define RCLCPP_COMPONENTS_LOCAL __attribute__ ((visibility("hidden")))
49  #else
50  #define RCLCPP_COMPONENTS_PUBLIC
51  #define RCLCPP_COMPONENTS_LOCAL
52  #endif
53  #define RCLCPP_COMPONENTS_PUBLIC_TYPE
54 #endif
55 
56 #endif // RCLCPP_COMPONENTS__VISIBILITY_CONTROL_HPP_