Helpers.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 #ifndef __IGN_TRANSPORT_HELPERS_HH_INCLUDED__
19 #define __IGN_TRANSPORT_HELPERS_HH_INCLUDED__
20 
21 #include <cstdio>
22 #include <cstring>
23 #include <string>
24 
27 
30 
31 #if defined BUILDING_STATIC_LIBS
32  #define IGNITION_VISIBLE
33  #define IGNITION_MSGS_VISIBLE
34  #define IGNITION_HIDDEN
35 #else
36  #if defined __WIN32 || defined __CYGWIN__
37  #ifdef BUILDING_DLL
38  #ifdef __GNUC__
39  #define IGNITION_VISIBLE __attribute__ ((dllexport))
40  #else
41  #define IGNITION_VISIBLE __declspec(dllexport)
42  #endif
43  #else
44  #ifdef __GNUC__
45  #define IGNITION_VISIBLE __attribute__ ((dllimport))
46  #else
47  #define IGNITION_VISIBLE __declspec(dllimport)
48  #endif
49  #endif
50  #define IGNITION_HIDDEN
51  #else
52  #if __GNUC__ >= 4
53  #define IGNITION_VISIBLE __attribute__ ((visibility ("default")))
54  #define IGNITION_HIDDEN __attribute__ ((visibility ("hidden")))
55  #else
56  #define IGNITION_VISIBLE
57  #define IGNITION_HIDDEN
58  #endif
59  #endif
60 
61  #if defined _WIN32 || defined __CYGWIN__
62  #ifdef BUILDING_DLL_IGNITION_MSGS
63  #ifdef __GNUC__
64  #define IGNITION_MSGS_VISIBLE __attribute__ ((dllexport))
65  #else
66  #define IGNITION_MSGS_VISIBLE __declspec(dllexport)
67  #endif
68  #else
69  #ifdef __GNUC__
70  #define IGNITION_MSGS_VISIBLE __attribute__ ((dllimport))
71  #else
72  #define IGNITION_MSGS_VISIBLE __declspec(dllimport)
73  #endif
74  #endif
75  #define IGNITION_MSGS_HIDDEN
76  #else
77  #if __GNUC__ >= 4
78  #define IGNITION_MSGS_VISIBLE __attribute__ ((visibility ("default")))
79  #define IGNITION_MSGS_HIDDEN __attribute__ ((visibility ("hidden")))
80  #else
81  #define IGNITION_MSGS_VISIBLE
82  #define IGNITION_MSGS_HIDDEN
83  #endif
84  #endif
85 // BUILDING_STATIC_LIBS
86 #endif
87 
88  namespace ignition
89  {
90  namespace transport
91  {
97  bool env(const std::string &_name,
98  std::string &_value);
99  }
100  }
101 
102 // Use safer functions on Windows
103 #ifdef _MSC_VER
104  #define ign_strcat strcat_s
105  #define ign_strcpy strcpy_s
106  #define ign_sprintf sprintf_s
107  #define ign_strdup _strdup
108 #else
109  #define ign_strcat std::strcat
110  #define ign_strcpy std::strcpy
111  #define ign_sprintf std::sprintf
112  #define ign_strdup strdup
113 #endif
114 
115 // __IGN_TRANSPORT_HELPERS_HH_INCLUDED__
116 #endif
#define IGNITION_VISIBLE
Use to represent "symbol visible" if supported.
Definition: Helpers.hh:56
Definition: AdvertiseOptions.hh:25
bool env(const std::string &_name, std::string &_value)
Find the environment variable &#39;_name&#39; and return its value.