23 #ifndef _cmnPortability_h
24 #define _cmnPortability_h
39 #define CISST_UNDEFINED 0
53 #define CISST_WINDOWS 1
55 #define CISST_RTLINUX 3
57 #define CISST_SOLARIS 5
58 #define CISST_LINUX_RTAI 6
59 #define CISST_CYGWIN 7
60 #define CISST_DARWIN 8
62 #define CISST_LINUX_XENOMAI 10
78 #define CISST_DOTNET7 3
79 #define CISST_SGI_CC 4
80 #define CISST_SUN_CC 5
81 #define CISST_INTEL_CC 6
82 #define CISST_DOTNET2003 7
83 #define CISST_DOTNET2005 8
84 #define CISST_DOTNET2008 9
85 #define CISST_DOTNET2010 10
86 #define CISST_DOTNET2012 11
87 #define CISST_DOTNET2013 12
88 #define CISST_CLANG 13
94 #define CISST_ILP32 1 // Integers, Longs and Pointers are 32 bits
95 #define CISST_LP64 2 // Longs and Pointers are 64 bits - Linux, MacOS 64
96 #define CISST_LLP64 3 // Long Longs and Pointers are 64 bits, longs are still 32 bits - Windows
105 #ifdef __GNUC__ // see man gcc
106 #define CISST_COMPILER CISST_GCC
107 #ifdef linux // see cpp -dM and ctrl+d
108 #define CISST_OS CISST_LINUX
110 #if CISST_HAS_LINUX_RTAI // overwrite if RTAI
112 #define CISST_OS CISST_LINUX_RTAI
114 #if CISST_HAS_LINUX_XENOMAI // overwrite if Xenomai
116 #define CISST_OS CISST_LINUX_XENOMAI
117 #endif // linux Xenomai
119 #define CISST_OS CISST_SOLARIS
122 #define CISST_OS CISST_IRIX
125 #define CISST_OS CISST_CYGWIN
128 #define CISST_OS CISST_DARWIN
131 #define CISST_OS CISST_QNX
135 #define CISST_OS CISST_IRIX
137 #define CISST_COMPILER CISST_SGI_CC
141 #define CISST_OS CISST_SOLARIS
143 #define CISST_COMPILER CISST_SUN_CC
150 #ifdef __clang__ // clang -dM -E -x c /dev/null
151 #undef CISST_COMPILER
152 #define CISST_COMPILER CISST_CLANG
157 #ifdef _WIN32 // see msdn.microsoft.com
160 #define _WIN32_WINNT 0x0500
162 #define CISST_OS CISST_WINDOWS
166 #define CISST_COMPILER_IS_MSVC
169 #define CISST_COMPILER_IS_MSVC_64
172 #if (_MSC_VER == 1200)
173 #define CISST_COMPILER CISST_VCPP6
174 #elif (_MSC_VER == 1300)
175 #define CISST_COMPILER CISST_DOTNET7
176 #elif (_MSC_VER == 1310)
177 #define CISST_COMPILER CISST_DOTNET2003
178 #elif (_MSC_VER == 1400)
179 #define CISST_COMPILER CISST_DOTNET2005
180 #elif (_MSC_VER == 1500)
181 #define CISST_COMPILER CISST_DOTNET2008
182 #elif (_MSC_VER == 1600)
183 #define CISST_COMPILER CISST_DOTNET2010
184 #elif (_MSC_VER == 1700)
185 #define CISST_COMPILER CISST_DOTNET2012
186 #elif (_MSC_VER >= 1800)
187 #define CISST_COMPILER CISST_DOTNET2013
195 #if defined(__INTEL_COMPILER)
196 #define CISST_COMPILER CISST_INTEL_CC
197 #if defined (__linux__) // linux
198 #define CISST_OS CISST_LINUX
200 #if CISST_HAS_LINUX_RTAI // overwrite if RTAI
202 #define CISST_OS CISST_LINUX_RTAI
204 #if CISST_HAS_LINUX_XENOMAI // overwrite if Xenomai
206 #define CISST_OS CISST_LINUX_XENOMAI
207 #endif // linux Xenomai
208 #ifndef CISST_OS // windows at last
209 #define CISST_OS CISST_WINDOWS
211 #endif // __INTEL_COMPILER
215 #ifndef CISST_COMPILER
216 #define CISST_COMPILER CISST_UNDEFINED
220 #define CISST_OS CISST_UNDEFINED
225 #if (CISST_OS == CISST_WINDOWS) || (CISST_OS == CISST_CYGWIN)
228 # define CISST_OS_IS_WINDOWS 1
240 # define CISST_OS_IS_WINDOWS 0
245 #if (CISST_COMPILER == CISST_GCC)
247 #define CISST_DATA_MODEL CISST_LP64
250 #define CISST_DATA_MODEL CISST_LLP64
253 #define CISST_DATA_MODEL CISST_ILP32
256 #endif // CISST_COMPILER == CISST_GCC
258 #if (CISST_COMPILER == CISST_CLANG)
259 #if defined(__LP64__) && __LP64__
260 #define CISST_DATA_MODEL CISST_LP64
262 #endif // CISST_COMPILER == CISST_CLANG
264 #ifdef CISST_COMPILER_IS_MSVC
265 #ifdef CISST_COMPILER_IS_MSVC_64
266 #define CISST_DATA_MODEL CISST_LLP64
268 #define CISST_DATA_MODEL CISST_ILP32
270 #endif // CISST_COMPILER_IS_MSVC
272 #ifndef CISST_DATA_MODEL
273 #define CISST_DATA_MODEL CISST_UNDEFINED
278 #endif // DOXYGEN end of doxygen section to skip
304 #if (CISST_COMPILER == CISST_GCC) || (CISST_COMPILER == CISST_CLANG)
305 #define CISST_DEPRECATED __attribute__ ((deprecated))
307 #ifdef CISST_COMPILER_IS_MSVC
308 #define CISST_DEPRECATED __declspec(deprecated)
310 #define CISST_DEPRECATED
322 #ifdef CISST_COMPILER_IS_MSVC
323 #pragma warning(disable: 4290 4251 4786)
324 #ifndef _CRT_NONSTDC_NO_DEPRECATE
325 #define _CRT_NONSTDC_NO_DEPRECATE
327 #ifndef _CRT_SECURE_NO_DEPRECATE
328 #define _CRT_SECURE_NO_DEPRECATE
330 #ifndef _SCL_SECURE_NO_DEPRECATE
331 #define _SCL_SECURE_NO_DEPRECATE
351 #if CISST_OS_IS_WINDOWS
383 #ifdef CISST_COMPILER_IS_MSVC
385 #define CMN_ISNAN(x) (_isnan(x) != 0)
387 #if (CISST_OS == CISST_DARWIN)
389 extern "C" int isnan (
double);
392 #define CMN_ISNAN(x) isnan(x)
415 #define CMN_ISFINITE(x) cmnIsFinite(x)
446 #if (CISST_COMPILER == CISST_DOTNET7)
447 #define CISST_DECLARE_TEMPLATE_FUNCTION_SPECIALIZATION template
448 #define CISST_DEFINE_TEMPLATE_FUNCTION_SPECIALIZATION
450 #define CISST_DECLARE_TEMPLATE_FUNCTION_SPECIALIZATION template<>
451 #define CISST_DEFINE_TEMPLATE_FUNCTION_SPECIALIZATION template<>
476 #if (CISST_COMPILER == CISST_GCC) || (CISST_COMPILER == CISST_CLANG)
477 #define CMN_UNUSED(argument) MARKED_AS_UNUSED ## argument __attribute__((unused))
479 #define CMN_UNUSED(argument) MARKED_AS_UNUSED ## argument
504 #if (CISST_COMPILER == CISST_DOTNET7) || (CISST_COMPILER == CISST_DOTNET2003) || (CISST_COMPILER == CISST_DOTNET2005)
505 #define CMN_DEFAULT_TEMPLATED_CONSTRUCTOR(type) type::type()
507 #define CMN_DEFAULT_TEMPLATED_CONSTRUCTOR(type) type()
514 #if (CISST_COMPILER == CISST_GCC) || (CISST_COMPILER == CISST_CLANG)
516 #define CMN_DO_PRAGMA(x) _Pragma (#x)
517 #define CMN_COMPILATION_WARNING(warningMessage) CMN_DO_PRAGMA(warning("Warning: " #warningMessage))
519 #ifdef CISST_COMPILER_IS_MSVC
520 #define CMN_COMPILATION_WARNING(warningMessage) __pragma(message("Warning: " ## warningMessage))
542 #ifdef CISST_COMPILER_IS_MSVC
544 #define CMN_PRETTY_FUNCTION __FUNCSIG__
546 #warning "With Visual Studio, you need /EP or /P to have __FUNCSIG__"
550 #elif (CISST_COMPILER == CISST_GCC) || (CISST_COMPILER == CISST_INTEL_CC) || (CISST_COMPILER == CISST_CLANG)
551 #define CMN_PRETTY_FUNCTION __PRETTY_FUNCTION__
557 #warning "Visual C++, GNU C++ and Intel CC are supported so far"
562 #ifndef CMN_PRETTY_FUNCTION
563 #define CMN_PRETTY_FUNCTION ""
569 #endif // _cmnPortability_h
#define CISST_EXPORT
Definition: cmnExportMacros.h:50
Macros to export the symbols of cisstCommon (in a Dll).
bool CISST_EXPORT cmnIsFinite(const float &value)
Detect a finite number.
CISST_EXPORT const std::string cmnCompilersStrings[]
CISST_EXPORT const std::string cmnOperatingSystemsStrings[]