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 #endif
44