Skip to content

Commit fa8bcfd

Browse files
committed
Improve portability. Fix C++98 build on MacOS
1 parent 4b838dd commit fa8bcfd

File tree

7 files changed

+29
-19
lines changed

7 files changed

+29
-19
lines changed

src/BitStreamException.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ namespace kanzi
5050

5151
int error() const { return _code; }
5252

53-
virtual ~BitStreamException() _GLIBCXX_USE_NOEXCEPT {}
53+
virtual ~BitStreamException() NOEXCEPT {}
5454
};
5555

5656
}

src/Context.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ namespace kanzi
3131
// The extra memory used does not matter for the application context since
3232
// the map is small.
3333
typedef struct ContextVal {
34-
bool isString;
3534
int64 lVal;
3635
std::string sVal;
36+
bool isString;
3737

38-
ContextVal(bool b, int64 val, const std::string& str) : isString(b), lVal(val), sVal(str) {}
38+
ContextVal(bool b, int64 val, const std::string& str) : lVal(val), sVal(str), isString(b) {}
3939
ContextVal() { isString = false; lVal = 0; }
4040
} ctxVal;
4141

src/Global.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ namespace kanzi {
5858

5959
private:
6060
Global();
61-
~Global() {};
61+
~Global() {}
6262

6363
static const Global _singleton;
6464
static const int LOG2_4096[257]; // 4096*Math.log2(x)

src/Memory.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ limitations under the License.
2121
#include "types.hpp"
2222

2323
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(BSD)
24-
#include <machine/endian.h>
25-
#elif defined(OS_MACOSX)
26-
#include <machine/endian.h>
24+
#include <machine/endian.h>
25+
#elif defined(__APPLE__)
26+
#include <machine/endian.h>
2727
#elif defined(__linux__) || defined(__linux) || defined(__gnu_linux__)
28-
#include <endian.h>
28+
#include <endian.h>
2929
#endif
3030

3131

src/concurrent.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,10 @@ class Task {
198198
#define ATOMIC_BOOL std::atomic_bool
199199

200200
#else
201-
#if __cplusplus < 201103L
201+
#if defined(__APPLE__)
202+
#define ATOMIC_INT std::atomic_int
203+
#define ATOMIC_BOOL std::atomic_bool
204+
#elif __cplusplus < 201103L
202205
// ! Stubs for NON CONCURRENT USAGE !
203206
// Used to compile and provide a non concurrent version AND
204207
// when atomic.h is not available (VS C++)

src/io/IOException.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ namespace kanzi
4545

4646
int error() const { return _code; }
4747

48-
~IOException() _GLIBCXX_USE_NOEXCEPT{}
48+
~IOException() NOEXCEPT {}
4949
};
5050

5151
}

src/types.hpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,20 +127,18 @@ limitations under the License.
127127
#endif
128128
#endif
129129

130-
#ifndef _GLIBCXX_USE_NOEXCEPT
131-
#define _GLIBCXX_USE_NOEXCEPT
132-
#endif
133-
134130
// Notice: in Visual Studio (prior to VS2017 version 15.7)
135131
// __cplusplus always defaults to 199711L (aka C++98) !!! (unless
136132
// the extra option /Zc:__cplusplus is added to the command line).
137133
// Otherwise, using the _MSVC_LANG macro returns the proper C++ version.
138134
#if __cplusplus >= 201103L
139135
// C++ 11
140136
#define FINAL final
137+
#define NOEXCEPT noexcept
141138
#include <cstdint>
142139
#else
143140
#define FINAL
141+
#define NOEXCEPT throw()
144142

145143
#if defined(_MSC_VER)
146144
#if _MSC_VER < 1300
@@ -167,12 +165,15 @@ limitations under the License.
167165
typedef unsigned char uint8_t;
168166
typedef unsigned short uint16_t;
169167
typedef unsigned int uint32_t;
170-
typedef signed long int64_t;
171-
typedef unsigned long uint64_t;
168+
169+
#if !defined(__APPLE__)
170+
typedef signed long int64_t;
171+
typedef unsigned long uint64_t;
172+
#endif
172173
#endif
173174

174175

175-
#if !defined(_MSC_VER) || _MSC_VER < 1910
176+
#if !defined(nullptr)
176177
#define nullptr NULL
177178
#endif
178179
#endif
@@ -193,11 +194,17 @@ namespace kanzi
193194
typedef uint8_t uint8;
194195
typedef int16_t int16;
195196
typedef int32_t int32;
196-
typedef int64_t int64;
197197
typedef uint16_t uint16;
198198
typedef uint32_t uint;
199199
typedef uint32_t uint32;
200-
typedef uint64_t uint64;
200+
201+
#if defined(__APPLE__)
202+
typedef signed long int64;
203+
typedef unsigned long uint64;
204+
#else
205+
typedef int64_t int64;
206+
typedef uint64_t uint64;
207+
#endif
201208
}
202209

203210
#if defined(__MINGW32__)

0 commit comments

Comments
 (0)