diff options
Diffstat (limited to 'CPP/Common/Common.h')
-rw-r--r-- | CPP/Common/Common.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/CPP/Common/Common.h b/CPP/Common/Common.h new file mode 100644 index 0000000..8dac613 --- /dev/null +++ b/CPP/Common/Common.h | |||
@@ -0,0 +1,57 @@ | |||
1 | // Common.h | ||
2 | |||
3 | #ifndef __COMMON_COMMON_H | ||
4 | #define __COMMON_COMMON_H | ||
5 | |||
6 | /* | ||
7 | This file is included to all cpp files in 7-Zip. | ||
8 | Each folder contains StdAfx.h file that includes "Common.h". | ||
9 | So 7-Zip includes "Common.h" in both modes: | ||
10 | with precompiled StdAfx.h | ||
11 | and | ||
12 | without precompiled StdAfx.h | ||
13 | |||
14 | If you use 7-Zip code, you must include "Common.h" before other h files of 7-zip. | ||
15 | If you don't need some things that are used in 7-Zip, | ||
16 | you can change this h file or h files included in this file. | ||
17 | */ | ||
18 | |||
19 | // compiler pragmas to disable some warnings | ||
20 | #include "../../C/Compiler.h" | ||
21 | |||
22 | // it's <windows.h> or code that defines windows things, if it's not _WIN32 | ||
23 | #include "MyWindows.h" | ||
24 | |||
25 | // NewHandler.h and NewHandler.cpp redefine operator new() to throw exceptions, if compiled with old MSVC compilers | ||
26 | #include "NewHandler.h" | ||
27 | |||
28 | |||
29 | |||
30 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) | ||
31 | |||
32 | |||
33 | /* There is BUG in MSVC 6.0 compiler for operator new[]: | ||
34 | It doesn't check overflow, when it calculates size in bytes for allocated array. | ||
35 | So we can use MY_ARRAY_NEW macro instead of new[] operator. */ | ||
36 | |||
37 | #if defined(_MSC_VER) && (_MSC_VER == 1200) && !defined(_WIN64) | ||
38 | #define MY_ARRAY_NEW(p, T, size) p = new T[(size > (unsigned)0xFFFFFFFF / sizeof(T)) ? (unsigned)0xFFFFFFFF / sizeof(T) : size]; | ||
39 | #else | ||
40 | #define MY_ARRAY_NEW(p, T, size) p = new T[size]; | ||
41 | #endif | ||
42 | |||
43 | #if (defined(__GNUC__) && (__GNUC__ >= 8)) | ||
44 | #define MY_ATTR_NORETURN __attribute__((noreturn)) | ||
45 | #elif (defined(__clang__) && (__clang_major__ >= 3)) | ||
46 | #if __has_feature(cxx_attributes) | ||
47 | #define MY_ATTR_NORETURN [[noreturn]] | ||
48 | #else | ||
49 | #define MY_ATTR_NORETURN __attribute__ ((noreturn)) | ||
50 | #endif | ||
51 | #elif (defined(_MSC_VER) && (_MSC_VER >= 1900)) | ||
52 | #define MY_ATTR_NORETURN [[noreturn]] | ||
53 | #else | ||
54 | #define MY_ATTR_NORETURN | ||
55 | #endif | ||
56 | |||
57 | #endif | ||