Ice 3.7 C++98 API Reference
Loading...
Searching...
No Matches
Config.h
Go to the documentation of this file.
1//
2// Copyright (c) ZeroC, Inc. All rights reserved.
3//
4
5#ifndef ICE_UTIL_CONFIG_H
6#define ICE_UTIL_CONFIG_H
7
8//
9// Use the system headers as preferred way to detect endianness
10// and fallback to architecture based checks.
11//
12//
13#include <stdlib.h>
14
15#if defined(__GLIBC__)
16# include <endian.h>
17#elif defined(__APPLE__)
18# include <machine/endian.h>
19#elif defined(__FreeBSD__)
20# include <sys/endian.h>
21#endif
22
23#if (defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && (__BYTE_ORDER == __LITTLE_ENDIAN)) || \
24 (defined(_BYTE_ORDER) && defined(_LITTLE_ENDIAN) && (_BYTE_ORDER == _LITTLE_ENDIAN)) || \
25 (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
26
27# define ICE_LITTLE_ENDIAN
28
29#elif (defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && (__BYTE_ORDER == __BIG_ENDIAN)) || \
30 (defined(_BYTE_ORDER) && defined(_BIG_ENDIAN) && (_BYTE_ORDER == _BIG_ENDIAN)) || \
31 (defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))
32
33# define ICE_BIG_ENDIAN
34
35#elif defined(__i386) || \
36 defined(_M_IX86) || \
37 defined(__x86_64) || \
38 defined(_M_X64) || \
39 defined(_M_IA64) || \
40 defined(__alpha__) || \
41 defined(__ARMEL__) || \
42 defined(_M_ARM64) || \
43 defined(_M_ARM_FP) || \
44 defined(__arm64) || \
45 defined(__MIPSEL__)
46
47# define ICE_LITTLE_ENDIAN
48
49#elif defined(__sparc) || \
50 defined(__sparc__) || \
51 defined(__hppa) || \
52 defined(__ppc__) || \
53 defined(__powerpc) || \
54 defined(_ARCH_COM) || \
55 defined(__MIPSEB__)
56
57# define ICE_BIG_ENDIAN
58
59#else
60
61# error "Unknown architecture"
62
63#endif
64
65#ifdef _MSC_VER
66
67# ifdef _WIN64
68# define ICE_64
69# else
70# define ICE_32
71# endif
72
73#else
74
75 //
76 // Use system headers as preferred way to detect 32 or 64 bit mode and
77 // fallback to architecture based checks
78 //
79# include <stdint.h>
80
81# if defined(__WORDSIZE) && (__WORDSIZE == 64)
82# define ICE_64
83# elif defined(__WORDSIZE) && (__WORDSIZE == 32)
84# define ICE_32
85# elif defined(__sun) && (defined(__sparcv9) || defined(__x86_64)) || \
86 defined(__linux__) && defined(__x86_64) || \
87 defined(__APPLE__) && defined(__x86_64) || \
88 defined(__hppa) && defined(__LP64__) || \
89 defined(_ARCH_COM) && defined(__64BIT__) || \
90 defined(__alpha__) || \
91 defined(_WIN64)
92# define ICE_64
93# else
94# define ICE_32
95# endif
96#endif
97
98#if defined(_MSVC_LANG)
99# define ICE_CPLUSPLUS _MSVC_LANG
100#else
101# define ICE_CPLUSPLUS __cplusplus
102#endif
103
104//
105// Check for C++ 11 support
106//
107// For GCC, we recognize --std=c++0x only for GCC version 4.5 and greater,
108// as C++11 support in prior releases was too limited.
109//
110#if (ICE_CPLUSPLUS >= 201103) || \
111 ((defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__) && ((__GNUC__* 100) + __GNUC_MINOR__) >= 405)) || \
112 (defined(_MSC_VER) && (_MSC_VER >= 1900))
113# define ICE_CPP11_COMPILER
114#endif
115
116//
117// Ensure the C++ compiler supports C++11 when using the C++11 mapping
118//
119#if defined(ICE_CPP11_MAPPING) && !defined(ICE_CPP11_COMPILER)
120# error "you need a C++11 capable compiler to use the C++11 mapping"
121#endif
122
123#if defined(ICE_CPP11_COMPILER)
124# define ICE_NOEXCEPT noexcept
125# define ICE_NOEXCEPT_FALSE noexcept(false)
126# define ICE_FINAL final
127#else
128# define ICE_NOEXCEPT throw()
129# define ICE_NOEXCEPT_FALSE /**/
130# define ICE_FINAL /**/
131#endif
132
133//
134// Does the C++ compiler library provide std::codecvt_utf8 and
135// std::codecvt_utf8_utf16?
136//
137#if (defined(_MSC_VER) && (_MSC_VER >= 1800)) || \
138 defined(__clang__) || \
139 (defined(ICE_CPP11_COMPILER) && defined(__GNUC__) && (__GNUC__ >= 5))
140# define ICE_HAS_CODECVT_UTF8
141#endif
142
143//
144// Support for thread-safe function local static initialization
145// (a.k.a. "magic statics")
146//
147#if defined(ICE_CPP11_MAPPING) || defined(__GNUC__) || defined(__clang__) || (defined(_MSC_VER) && (_MSC_VER >= 1900))
148# define ICE_HAS_THREAD_SAFE_LOCAL_STATIC
149#endif
150
151//
152// Compiler extensions to export and import symbols: see the documentation
153// for Visual Studio, Solaris Studio and GCC.
154//
155#if defined(_MSC_VER)
156# define ICE_DECLSPEC_EXPORT __declspec(dllexport)
157# define ICE_DECLSPEC_IMPORT __declspec(dllimport)
158// With Visual Studio, we can import/export member functions without importing/
159// exporting the whole class
160# define ICE_MEMBER_IMPORT_EXPORT
161#elif (defined(__GNUC__) || defined(__clang__) || defined(__IBMCPP__)) && !defined(__ibmxl__)
162# define ICE_DECLSPEC_EXPORT __attribute__((visibility ("default")))
163# define ICE_DECLSPEC_IMPORT __attribute__((visibility ("default")))
164#elif defined(__SUNPRO_CC)
165# define ICE_DECLSPEC_EXPORT __global
166# define ICE_DECLSPEC_IMPORT /**/
167#else
168# define ICE_DECLSPEC_EXPORT /**/
169# define ICE_DECLSPEC_IMPORT /**/
170#endif
171
172#ifdef ICE_MEMBER_IMPORT_EXPORT
173# define ICE_CLASS(API) /**/
174# define ICE_MEMBER(API) API
175#else
176# define ICE_CLASS(API) API
177# define ICE_MEMBER(API) /**/
178#endif
179
180// With IBM xlC, the visibility attribute must be at the end of the
181// declaration of global variables.
182#if defined(__IBMCPP__) && !defined(ICE_STATIC_LIBS)
183# define ICE_GLOBAL_VAR_SUFFIX __attribute__((visibility ("default")))
184#else
185# define ICE_GLOBAL_VAR_SUFFIX /**/
186#endif
187
188//
189// Let's use these extensions with Ice:
190//
191#ifndef ICE_API
192# if defined(ICE_STATIC_LIBS)
193# define ICE_API /**/
194# elif defined(ICE_API_EXPORTS)
195# define ICE_API ICE_DECLSPEC_EXPORT
196# else
197# define ICE_API ICE_DECLSPEC_IMPORT
198# endif
199#endif
200
201#if defined(_MSC_VER)
202# define ICE_DEPRECATED_API(msg) __declspec(deprecated(msg))
203#elif defined(__clang__)
204# if __has_extension(attribute_deprecated_with_message)
205# define ICE_DEPRECATED_API(msg) __attribute__((deprecated(msg)))
206# else
207# define ICE_DEPRECATED_API(msg) __attribute__((deprecated))
208# endif
209#elif defined(__GNUC__)
210# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
211// The message option was introduced in GCC 4.5
212# define ICE_DEPRECATED_API(msg) __attribute__((deprecated(msg)))
213# else
214# define ICE_DEPRECATED_API(msg) __attribute__((deprecated))
215# endif
216#else
217# define ICE_DEPRECATED_API(msg) /**/
218#endif
219
220#if defined(__clang__) || defined(__GNUC__)
221# define ICE_MAYBE_UNUSED __attribute__((unused))
222#else
223# define ICE_MAYBE_UNUSED /**/
224#endif
225
226#ifdef _WIN32
227# include <windows.h>
228
229# if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x600)
230//
231// Windows provides native condition variables on Vista and later
232//
233# ifndef ICE_HAS_WIN32_CONDVAR
234# define ICE_HAS_WIN32_CONDVAR
235# endif
236# endif
237#endif
238
239//
240// Some include files we need almost everywhere.
241//
242#include <cassert>
243#include <iostream>
244#include <sstream>
245#include <exception>
246#include <stdexcept>
247
248#ifndef _WIN32
249# include <pthread.h>
250# include <errno.h>
251# include <unistd.h>
252#endif
253
254#ifdef __APPLE__
255# include <TargetConditionals.h>
256#endif
257
258#if defined(_AIX) && defined(_LARGE_FILES)
259 // defines macros such as open that we want to use consistently everywhere
260# include <fcntl.h>
261#endif
262
263#ifdef __IBMCPP__
264 // TODO: better fix for this warning
265# pragma report(disable, "1540-0198") // private inheritance without private keyword
266#endif
267
268//
269// The Ice version.
270//
271#define ICE_STRING_VERSION "3.7.11" // "A.B.C", with A=major, B=minor, C=patch
272#define ICE_INT_VERSION 30711 // AABBCC, with AA=major, BB=minor, CC=patch
273#define ICE_SO_VERSION "37" // "ABC", with A=major, B=minor, C=patch
274
275#if !defined(ICE_BUILDING_ICE) && defined(ICE_API_EXPORTS)
276# define ICE_BUILDING_ICE
277#endif
278
279#if defined(_MSC_VER)
280# if !defined(ICE_STATIC_LIBS) && (!defined(_DLL) || !defined(_MT))
281# error "Only multi-threaded DLL libraries can be used with Ice!"
282# endif
283
284# ifdef ICE_CPP11_MAPPING
285# if defined(_DEBUG)
286# define ICE_LIBNAME(NAME) NAME ICE_SO_VERSION "++11D.lib"
287# else
288# define ICE_LIBNAME(NAME) NAME ICE_SO_VERSION "++11.lib"
289# endif
290# else
291# if defined(_DEBUG)
292# define ICE_LIBNAME(NAME) NAME ICE_SO_VERSION "D.lib"
293# else
294# define ICE_LIBNAME(NAME) NAME ICE_SO_VERSION ".lib"
295# endif
296# endif
297
298//
299// Automatically link with Ice[D|++11|++11D].lib
300//
301# if !defined(ICE_BUILDING_ICE) && !defined(ICE_BUILDING_SLICE_COMPILERS)
302# pragma comment(lib, ICE_LIBNAME("Ice"))
303# endif
304#endif
305
306namespace IceUtil
307{
308
309//
310// By deriving from this class, other classes are made non-copyable.
311//
313{
314protected:
315
317 ~noncopyable() { } // May not be virtual! Classes without virtual
318 // operations also derive from noncopyable.
319
320private:
321
322 noncopyable(const noncopyable&);
323 const noncopyable& operator=(const noncopyable&);
324};
325
326typedef unsigned char Byte;
327
328//
329// Int64 typedef and ICE_INT64 macro for Int64 literal values
330//
331// Note that on Windows, long is always 32-bit
332//
333#if defined(_WIN32) && defined(_MSC_VER)
334typedef __int64 Int64;
335# define ICE_INT64(n) n##i64
336# define ICE_INT64_FORMAT "%lld"
337#elif defined(ICE_64) && !defined(_WIN32)
338typedef long Int64;
339# define ICE_INT64(n) n##L
340# define ICE_INT64_FORMAT "%ld"
341#else
342typedef long long Int64;
343# define ICE_INT64(n) n##LL
344# define ICE_INT64_FORMAT "%lld"
345#endif
346
347}
348
349//
350// Macros to facilitate C++98 -> C++11 transition
351//
352#ifdef ICE_CPP11_MAPPING // C++11 mapping
353# include <memory>
354# include <future>
355# define ICE_HANDLE ::std::shared_ptr
356# define ICE_INTERNAL_HANDLE ::std::shared_ptr
357# define ICE_PROXY_HANDLE ::std::shared_ptr
358# define ICE_MAKE_SHARED(T, ...) ::std::make_shared<T>(__VA_ARGS__)
359# define ICE_DEFINE_PTR(TPtr, T) using TPtr = ::std::shared_ptr<T>
360# define ICE_ENUM(CLASS,ENUMERATOR) CLASS::ENUMERATOR
361# define ICE_SCOPED_ENUM(CLASS,ENUMERATOR) CLASS::ENUMERATOR
362# define ICE_NULLPTR nullptr
363# define ICE_DYNAMIC_CAST(T,V) ::std::dynamic_pointer_cast<T>(V)
364# define ICE_SHARED_FROM_THIS shared_from_this()
365# define ICE_SHARED_FROM_CONST_THIS(T) const_cast<T*>(this)->shared_from_this()
366# define ICE_GET_SHARED_FROM_THIS(p) p->shared_from_this()
367# define ICE_CHECKED_CAST(T, ...) Ice::checkedCast<T>(__VA_ARGS__)
368# define ICE_UNCHECKED_CAST(T, ...) Ice::uncheckedCast<T>(__VA_ARGS__)
369# define ICE_DELEGATE(T) T
370# define ICE_IN(...) __VA_ARGS__
371# define ICE_SET_EXCEPTION_FROM_CLONE(T, V) T = V
372#else // C++98 mapping
373# define ICE_HANDLE ::IceUtil::Handle
374# define ICE_INTERNAL_HANDLE ::IceInternal::Handle
375# define ICE_PROXY_HANDLE ::IceInternal::ProxyHandle
376# define ICE_MAKE_SHARED(T, ...) new T(__VA_ARGS__)
377# define ICE_DEFINE_PTR(TPtr, T) typedef ::IceUtil::Handle<T> TPtr
378# define ICE_ENUM(CLASS,ENUMERATOR) ENUMERATOR
379# define ICE_SCOPED_ENUM(CLASS,ENUMERATOR) CLASS##ENUMERATOR
380# define ICE_NULLPTR 0
381# define ICE_DYNAMIC_CAST(T,V) T##Ptr::dynamicCast(V)
382# define ICE_SHARED_FROM_THIS this
383# define ICE_SHARED_FROM_CONST_THIS(T) const_cast<T*>(this)
384# define ICE_GET_SHARED_FROM_THIS(p) p
385# define ICE_CHECKED_CAST(T, ...) T::checkedCast(__VA_ARGS__)
386# define ICE_UNCHECKED_CAST(T, ...) T::uncheckedCast(__VA_ARGS__)
387# define ICE_DELEGATE(T) T##Ptr
388# define ICE_IN(...) const __VA_ARGS__&
389# define ICE_SET_EXCEPTION_FROM_CLONE(T, V) T.reset(V)
390#endif
391
392#endif
#define ICE_API
Definition Config.h:197
Definition Config.h:313
noncopyable()
Definition Config.h:316
~noncopyable()
Definition Config.h:317
Definition Cond.h:39
long long Int64
Definition Config.h:342
unsigned char Byte
Definition Config.h:326