rcutils  master
C API providing common utilities and data structures.
visibility_control_macros.h
Go to the documentation of this file.
1 // Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
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 #ifndef RCUTILS__VISIBILITY_CONTROL_MACROS_H_
16 #define RCUTILS__VISIBILITY_CONTROL_MACROS_H_
17 
46 
47 #if defined(_MSC_VER) || defined(__CYGWIN__)
48 // Use the Windows syntax when compiling with Microsoft Visual C++.
49 //
50 // GCC on Windows also support this syntax. When compiling with cygwin,
51 // prefer using dllimport/dllexport are the semantic of those flags is closer
52 // to msvc++ behavior. See GCC documentation:
53 // https://gcc.gnu.org/onlinedocs/gcc/Microsoft-Windows-Function-Attributes.html
54 # define RCUTILS_IMPORT __declspec(dllimport)
55 # define RCUTILS_EXPORT __declspec(dllexport)
56 # define RCUTILS_LOCAL
57 #else // defined(_MSC_VER) || defined(__CYGWIN__)
58 // On Linux, use the GCC syntax. This syntax is understood by other compilers
59 // such as clang, icpc, and xlc++.
60 # define RCUTILS_IMPORT __attribute__ ((visibility("default")))
61 # define RCUTILS_EXPORT __attribute__ ((visibility("default")))
62 # define RCUTILS_LOCAL __attribute__ ((visibility("hidden")))
63 #endif // !defined(_MSC_VER) && !defined(__CYGWIN__)
64 
65 #endif // RCUTILS__VISIBILITY_CONTROL_MACROS_H_