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 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330
|
// Common0.h
#if defined(_MSC_VER) && _MSC_VER >= 1800
#pragma warning(disable : 4464) // relative include path contains '..'
#endif
#ifndef ZIP7_INC_COMMON0_H
#define ZIP7_INC_COMMON0_H
#include "../../C/Compiler.h"
/*
This file contains compiler related things for cpp files.
This file is included to all cpp files in 7-Zip via "Common.h".
Also this file is included in "IDecl.h" (that is included in interface files).
So external modules can use 7-Zip interfaces without
predefined macros defined in "Common.h".
*/
#ifdef _MSC_VER
#pragma warning(disable : 4710) // function not inlined
// 'CUncopyable::CUncopyable':
#pragma warning(disable : 4514) // unreferenced inline function has been removed
#if _MSC_VER < 1300
#pragma warning(disable : 4702) // unreachable code
#pragma warning(disable : 4714) // function marked as __forceinline not inlined
#pragma warning(disable : 4786) // identifier was truncated to '255' characters in the debug information
#endif
#if _MSC_VER < 1400
#pragma warning(disable : 4511) // copy constructor could not be generated // #pragma warning(disable : 4512) // assignment operator could not be generated
#pragma warning(disable : 4512) // assignment operator could not be generated
#endif
#if _MSC_VER > 1400 && _MSC_VER <= 1900
// #pragma warning(disable : 4996)
// strcat: This function or variable may be unsafe
// GetVersion was declared deprecated
#endif
#if _MSC_VER > 1200
// -Wall warnings
#if _MSC_VER <= 1600
#pragma warning(disable : 4917) // 'OLE_HANDLE' : a GUID can only be associated with a class, interface or namespace
#endif
// #pragma warning(disable : 4061) // enumerator '' in switch of enum '' is not explicitly handled by a case label
// #pragma warning(disable : 4266) // no override available for virtual member function from base ''; function is hidden
#pragma warning(disable : 4625) // copy constructor was implicitly defined as deleted
#pragma warning(disable : 4626) // assignment operator was implicitly defined as deleted
#if _MSC_VER >= 1600 && _MSC_VER < 1920
#pragma warning(disable : 4571) // Informational: catch(...) semantics changed since Visual C++ 7.1; structured exceptions (SEH) are no longer caught
#endif
#if _MSC_VER >= 1600
#pragma warning(disable : 4365) // 'initializing' : conversion from 'int' to 'unsigned int', signed / unsigned mismatch
#endif
#if _MSC_VER < 1800
// we disable the warning, if we don't use 'final' in class
#pragma warning(disable : 4265) // class has virtual functions, but destructor is not virtual
#endif
#if _MSC_VER >= 1900
#pragma warning(disable : 5026) // move constructor was implicitly defined as deleted
#pragma warning(disable : 5027) // move assignment operator was implicitly defined as deleted
#endif
#if _MSC_VER >= 1912
#pragma warning(disable : 5039) // pointer or reference to potentially throwing function passed to 'extern "C"' function under - EHc.Undefined behavior may occur if this function throws an exception.
#endif
#if _MSC_VER >= 1925
// #pragma warning(disable : 5204) // 'ISequentialInStream' : class has virtual functions, but its trivial destructor is not virtual; instances of objects derived from this class may not be destructed correctly
#endif
#if _MSC_VER >= 1934
// #pragma warning(disable : 5264) // const variable is not used
#endif
#endif // _MSC_VER > 1200
#endif // _MSC_VER
#if defined(_MSC_VER) // && !defined(__clang__)
#define Z7_DECLSPEC_NOTHROW __declspec(nothrow)
#elif defined(__clang__) || defined(__GNUC__)
#define Z7_DECLSPEC_NOTHROW __attribute__((nothrow))
#else
#define Z7_DECLSPEC_NOTHROW
#endif
/*
#if defined (_MSC_VER) && _MSC_VER >= 1900 \
|| defined(__clang__) && __clang_major__ >= 6 \
|| defined(__GNUC__) && __GNUC__ >= 6
#define Z7_noexcept noexcept
#else
#define Z7_noexcept throw()
#endif
*/
#if defined(__clang__)
#if /* defined(_WIN32) && */ __clang_major__ >= 16
#pragma GCC diagnostic ignored "-Wc++98-compat-pedantic"
#endif
#if __clang_major__ >= 4 && __clang_major__ < 12 && !defined(_WIN32)
/*
if compiled with new GCC libstdc++, GCC libstdc++ can use:
13.2.0/include/c++/
<new> : #define _NEW
<stdlib.h> : #define _GLIBCXX_STDLIB_H 1
*/
#pragma GCC diagnostic ignored "-Wreserved-id-macro"
#endif
// noexcept, final, = delete
#pragma GCC diagnostic ignored "-Wc++98-compat"
#if __clang_major__ >= 4
// throw() dynamic exception specifications are deprecated
#pragma GCC diagnostic ignored "-Wdeprecated-dynamic-exception-spec"
#endif
#if __clang_major__ <= 6 // check it
#pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
#pragma GCC diagnostic ignored "-Wold-style-cast"
#pragma GCC diagnostic ignored "-Wglobal-constructors"
#pragma GCC diagnostic ignored "-Wexit-time-destructors"
#if defined(Z7_LLVM_CLANG_VERSION) && __clang_major__ >= 18 // 18.1.0RC
#pragma GCC diagnostic ignored "-Wswitch-default"
#endif
// #pragma GCC diagnostic ignored "-Wunused-private-field"
// #pragma GCC diagnostic ignored "-Wnonportable-system-include-path"
// #pragma GCC diagnostic ignored "-Wsuggest-override"
// #pragma GCC diagnostic ignored "-Wsign-conversion"
// #pragma GCC diagnostic ignored "-Winconsistent-missing-override"
// #pragma GCC diagnostic ignored "-Wsuggest-destructor-override"
// #pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
// #pragma GCC diagnostic ignored "-Wdeprecated-copy-with-user-provided-dtor"
// #pragma GCC diagnostic ignored "-Wdeprecated-copy-dtor"
// #ifndef _WIN32
// #pragma GCC diagnostic ignored "-Wweak-vtables"
// #endif
/*
#if defined(Z7_GCC_VERSION) && (Z7_GCC_VERSION >= 40400) \
|| defined(Z7_CLANG_VERSION) && (Z7_CLANG_VERSION >= 30000)
// enumeration values not explicitly handled in switch
#pragma GCC diagnostic ignored "-Wswitch-enum"
#endif
*/
#endif // __clang__
#ifdef __GNUC__
// #pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor"
#endif
/* There is BUG in MSVC 6.0 compiler for operator new[]:
It doesn't check overflow, when it calculates size in bytes for allocated array.
So we can use Z7_ARRAY_NEW macro instead of new[] operator. */
#if defined(_MSC_VER) && (_MSC_VER == 1200) && !defined(_WIN64)
#define Z7_ARRAY_NEW(p, T, size) p = new T[((size) > 0xFFFFFFFFu / sizeof(T)) ? 0xFFFFFFFFu / sizeof(T) : (size)];
#else
#define Z7_ARRAY_NEW(p, T, size) p = new T[size];
#endif
#if (defined(__GNUC__) && (__GNUC__ >= 8))
#define Z7_ATTR_NORETURN __attribute__((noreturn))
#elif (defined(__clang__) && (__clang_major__ >= 3))
#if __has_feature(cxx_attributes)
#define Z7_ATTR_NORETURN [[noreturn]]
#else
#define Z7_ATTR_NORETURN __attribute__((noreturn))
#endif
#elif (defined(_MSC_VER) && (_MSC_VER >= 1900))
#define Z7_ATTR_NORETURN [[noreturn]]
#else
#define Z7_ATTR_NORETURN
#endif
// final in "GCC 4.7.0"
// In C++98 and C++03 code the alternative spelling __final can be used instead (this is a GCC extension.)
#if defined (__cplusplus) && __cplusplus >= 201103L \
|| defined(_MSC_VER) && _MSC_VER >= 1800 \
|| defined(__clang__) && __clang_major__ >= 4 \
/* || defined(__GNUC__) && __GNUC__ >= 9 */
#define Z7_final final
#if defined(__clang__) && __cplusplus < 201103L
#pragma GCC diagnostic ignored "-Wc++11-extensions"
#endif
#elif defined (__cplusplus) && __cplusplus >= 199711L \
&& defined(__GNUC__) && __GNUC__ >= 4 && !defined(__clang__)
#define Z7_final __final
#else
#define Z7_final
#if defined(__clang__) && __clang_major__ >= 4 \
|| defined(__GNUC__) && __GNUC__ >= 4
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
#pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor"
#endif
#endif
#define Z7_class_final(c) class c Z7_final
#if defined (__cplusplus) && __cplusplus >= 201103L \
|| (defined(_MSC_VER) && _MSC_VER >= 1800)
#define Z7_CPP_IS_SUPPORTED_default
#define Z7_eq_delete = delete
// #define Z7_DECL_DEFAULT_COPY_CONSTRUCTOR_IF_SUPPORTED(c) c(const c& k) = default;
#else
#define Z7_eq_delete
// #define Z7_DECL_DEFAULT_COPY_CONSTRUCTOR_IF_SUPPORTED(c)
#endif
#if defined(__cplusplus) && (__cplusplus >= 201103L) \
|| defined(_MSC_VER) && (_MSC_VER >= 1400) /* && (_MSC_VER != 1600) */ \
|| defined(__clang__) && __clang_major__ >= 4
#if defined(_MSC_VER) && (_MSC_VER == 1600) /* && (_MSC_VER != 1600) */
#pragma warning(disable : 4481) // nonstandard extension used: override specifier 'override'
#define Z7_DESTRUCTOR_override
#else
#define Z7_DESTRUCTOR_override override
#endif
#define Z7_override override
#else
#define Z7_override
#define Z7_DESTRUCTOR_override
#endif
#define Z7_CLASS_NO_COPY(cls) \
private: \
cls(const cls &) Z7_eq_delete; \
cls &operator=(const cls &) Z7_eq_delete;
class CUncopyable
{
protected:
CUncopyable() {} // allow constructor
// ~CUncopyable() {}
Z7_CLASS_NO_COPY(CUncopyable)
};
#define MY_UNCOPYABLE :private CUncopyable
// #define MY_UNCOPYABLE
// typedef void (*Z7_void_Function)(void);
#if defined(__clang__) || defined(__GNUC__)
#define Z7_CAST_FUNC(t, e) reinterpret_cast<t>(reinterpret_cast<Z7_void_Function>(e))
#else
#define Z7_CAST_FUNC(t, e) reinterpret_cast<t>(reinterpret_cast<void*>(e))
// #define Z7_CAST_FUNC(t, e) reinterpret_cast<t>(e)
#endif
#define Z7_GET_PROC_ADDRESS(func_type, hmodule, func_name) \
Z7_CAST_FUNC(func_type, GetProcAddress(hmodule, func_name))
// || defined(__clang__)
// || defined(__GNUC__)
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
#define Z7_DECLSPEC_NOVTABLE __declspec(novtable)
#else
#define Z7_DECLSPEC_NOVTABLE
#endif
#ifdef __clang__
#define Z7_PURE_INTERFACES_BEGIN \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wnon-virtual-dtor\"")
_Pragma("GCC diagnostic ignored \"-Wweak-vtables\"")
#define Z7_PURE_INTERFACES_END \
_Pragma("GCC diagnostic pop")
#else
#define Z7_PURE_INTERFACES_BEGIN
#define Z7_PURE_INTERFACES_END
#endif
// NewHandler.h and NewHandler.cpp redefine operator new() to throw exceptions, if compiled with old MSVC compilers
#include "NewHandler.h"
/*
// #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(a) Z7_ARRAY_SIZE(a)
#endif
*/
#endif // ZIP7_INC_COMMON0_H
// #define Z7_REDEFINE_NULL
#if defined(Z7_REDEFINE_NULL) /* && (!defined(__clang__) || defined(_MSC_VER)) */
// NULL is defined in <stddef.h>
#include <stddef.h>
#undef NULL
#ifdef __cplusplus
#if defined (__cplusplus) && __cplusplus >= 201103L \
|| (defined(_MSC_VER) && _MSC_VER >= 1800)
#define NULL nullptr
#else
#define NULL 0
#endif
#else
#define NULL ((void *)0)
#endif
#else // Z7_REDEFINE_NULL
#if defined(__clang__) && __clang_major__ >= 5
#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
#endif
#endif // Z7_REDEFINE_NULL
// for precompiler:
// #include "MyWindows.h"
|