tracetools  master
Tracing tools and instrumentation for ROS 2
visibility_control.hpp
Go to the documentation of this file.
1 // Copyright 2015 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 TRACETOOLS headers which declare symbols
16  * which are defined in the TRACETOOLS library. When not building the TRACETOOLS
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 TRACETOOLS
19  * library cannot have, but the consuming code must have inorder to link.
20  */
21 
22 #ifndef TRACETOOLS__VISIBILITY_CONTROL_HPP_
23 #define TRACETOOLS__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 TRACETOOLS_EXPORT __attribute__ ((dllexport))
31  #define TRACETOOLS_IMPORT __attribute__ ((dllimport))
32  #else
33  #define TRACETOOLS_EXPORT __declspec(dllexport)
34  #define TRACETOOLS_IMPORT __declspec(dllimport)
35  #endif
36  #ifdef TRACETOOLS_BUILDING_DLL
37  #define TRACETOOLS_PUBLIC TRACETOOLS_EXPORT
38  #else
39  #define TRACETOOLS_PUBLIC TRACETOOLS_IMPORT
40  #endif
41  #define TRACETOOLS_PUBLIC_TYPE TRACETOOLS_PUBLIC
42  #define TRACETOOLS_LOCAL
43 #else
44  #define TRACETOOLS_EXPORT __attribute__ ((visibility("default")))
45  #define TRACETOOLS_IMPORT
46  #if __GNUC__ >= 4
47  #define TRACETOOLS_PUBLIC __attribute__ ((visibility("default")))
48  #define TRACETOOLS_LOCAL __attribute__ ((visibility("hidden")))
49  #else
50  #define TRACETOOLS_PUBLIC
51  #define TRACETOOLS_LOCAL
52  #endif
53  #define TRACETOOLS_PUBLIC_TYPE
54 #endif
55 
56 #endif // TRACETOOLS__VISIBILITY_CONTROL_HPP_