summaryrefslogtreecommitdiff
path: root/cpp/include/IceUtil/Config.h
blob: 0e2a07026da7867b4e445a5275685e8fc71d0690 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
// **********************************************************************
//
// Copyright (c) 2003
// ZeroC, Inc.
// Billerica, MA, USA
//
// All Rights Reserved.
//
// Ice is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License version 2 as published by
// the Free Software Foundation.
//
// **********************************************************************

#ifndef ICE_UTIL_CONFIG_H
#define ICE_UTIL_CONFIG_H


//
// Endianness: define ICE_UTIL_BIGENDIAN on big endian platforms,
// nothing on little endian platforms.

#if defined(__sparc)
#define ICE_UTIL_BIGENDIAN
#endif


//
// For STLport. If we compile in debug mode, we want to use the debug
// STLport library. This is done by setting _STLP_DEBUG before any
// STLport header files are included.
//
#if !defined(NDEBUG) && !defined(_STLP_DEBUG)
#   define _STLP_DEBUG
#endif

#if defined(_WIN32)

// Necessary for TryEnterCriticalSection.
#   define _WIN32_WINNT 0x0400

#   if !defined(_UNICODE)
#       error "Only unicode libraries can be used with Ice!"
#   endif

#   if !defined(_DLL) || !defined(_MT)
#       error "Only multi-threaded DLL libraries can be used with Ice!"
#   endif

#   ifdef ICE_UTIL_API_EXPORTS
#       define ICE_UTIL_API __declspec(dllexport)
#   else
#       define ICE_UTIL_API __declspec(dllimport)
#   endif

#   include <windows.h>

// '...' : forcing value to bool 'true' or 'false' (performance warning)
#   pragma warning( disable : 4800 )
// ... identifier was truncated to '255' characters in the debug information
#   pragma warning( disable : 4786 )
// 'this' : used in base member initializer list
#   pragma warning( disable : 4355 )
// class ... needs to have dll-interface to be used by clients of class ...
#   pragma warning( disable : 4251 )
// ... : inherits ... via dominance
#   pragma warning( disable : 4250 )
// non dll-interface class ... used as base for dll-interface class ...
#   pragma warning( disable : 4275 )
//  ...: decorated name length exceeded, name was truncated
#   pragma warning( disable : 4503 )  

#   define SIZEOF_WCHAR_T 2

#elif (defined(__linux) || defined(__FreeBSD__)) && defined(__i386)

#   define ICE_UTIL_API /**/
#   define HAVE_READLINE
#   define SIZEOF_WCHAR_T 4

//
// The ISO C99 standard specifies that in C++ implementations the
// macros for minimum/maximum integer values should only be defined if
// explicitly requested with __STDC_LIMIT_MACROS.
//
#   define __STDC_LIMIT_MACROS
#   include <stdint.h>

#elif defined(__sun) && defined(__sparc)

#   define ICE_UTIL_API /**/
#   define SIZEOF_WCHAR_T 4
#   include <inttypes.h>

#else

#   error "unsupported operating system or platform"

#endif


//
// Some include files we need almost everywhere.
//
#include <cassert>
#include <iostream>
#include <sstream>

#ifndef _WIN32
#   include <pthread.h>
#   include <errno.h>
#endif

//
// By deriving from this class, other classes are made non-copyable.
//
namespace IceUtil
{

//
// TODO: Constructor and destructor should not be inlined, as they are
// not performance critical.
//
// TODO: Naming conventions?
//
class noncopyable
{
protected:

    noncopyable() { }
    ~noncopyable() { } // May not be virtual! Classes without virtual operations also derive from noncopyable.

private:

    noncopyable(const noncopyable&);
    const noncopyable& operator=(const noncopyable&);
};

//
// Some definitions for 64-bit integers.
//
#if defined(_WIN32)

typedef __int64 Int64;
const Int64 Int64Min = -9223372036854775808i64;
const Int64 Int64Max =  9223372036854775807i64;

#   define ICE_INT64(x) Int64(x##i64)

#else

#   if defined(INT64_MIN) && defined(INT64_MAX)

typedef int64_t Int64;
const Int64 Int64Min = INT64_MIN;
const Int64 Int64Max = INT64_MAX;

#   else

typedef long long Int64;
const Int64 Int64Min = -0x7fffffffffffffffLL-1LL;
const Int64 Int64Max = 0x7fffffffffffffffLL;

#   endif

#define ICE_INT64(x) Int64(x##LL)

#endif

}

//
// The Ice version.
//
#define ICE_STRING_VERSION "1.0.1" // "A.B.C", with A=major, B=minor, C=patch
#define ICE_INT_VERSION 10001      // AABBCC, with AA=major, BB=minor, CC=patch

#endif