Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
GrayCore.h
Go to the documentation of this file.
1 //
5 
6 #ifndef _INC_GrayCore_H
7 #define _INC_GrayCore_H 0x003
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 // Pull in my system/compiler CLR includes and arbitrate them with common names.
13 #include "SysTypes.h"
14 
15 // override the system #define UNICODE and _UNICODE. I use my own USE_UNICODE system as default char type. We don't have to use UNICODE just because the system does.
16 #ifndef USE_UNICODE
17 #if defined(UNICODE) // || defined(_UNICODE)
18 #define USE_UNICODE 1
19 #else
20 #define USE_UNICODE 0 // same as _MBCS
21 #endif
22 #endif
23 #ifndef USE_UNICODE_FN
24 #define USE_UNICODE_FN USE_UNICODE
25 #endif
26 
27 namespace Gray
28 {
32 #ifndef GRAY_NAME
33 #define GRAY_NAME Gray
34 #define GRAY_NAMES "Gray"
35 #endif
36 #define GRAYCALL __stdcall
37 
38 #if ! defined(GRAY_STATICLIB)
39 #define GRAY_DLL // We are building Gray DLL/SO instead of static lib. use __DECL_IMPORT or __DECL_EXPORT. opposite of GRAY_STATICLIB
40 #endif
41 
42  // use _LIB && _WINDLL && _MFC_VER to identify the type of LIB build. or it may just be who is including us.
43 #ifndef GRAYCORE_LINK
44 #if defined(_MFC_VER) || defined(GRAY_STATICLIB) // GRAY_STATICLIB or _MFC_VER can be defined to make Gray* all static lib
45 #define GRAYCORE_LINK
46 #else
47 #define GRAYCORE_LINK __DECL_IMPORT // default is to include from a DLL/SO (GRAY_DLL)
48 #endif
49 #endif
50 
51 #if defined(_DEBUG) || ! defined(_MSC_VER)
52 #define _LOCCALL // static (local) calls might have better calling conventions? But turn off during _DEBUG
53 #else
54 #define _LOCCALL __fastcall // Local procedure name modifier. will not stack dump properly!
55 #endif
56 
57 #if defined(__GNUC__) || (! defined(_MSC_VER)) || (_MSC_VER < 1600)
58 #define __noop ((void)0) // A macro that does nothing. Compiles out some code. do { } while( 0 )
59 #endif
60 
61 #if defined(_MSC_VER) && _MSC_VER <= 1600 // No C++11 features.
62  // Get rid of C++11 features. e.g. "= delete" and override
63 #define noexcept
64 #define override // tell the compiler this is an intentional override
65 #define IS_DELETE
66 #else
67 #define IS_DELETE = delete // get rid of this normally default supplied method.
68 #endif
69 
70 #if defined(_MSC_VER) && _MSC_VER <= 1916 // VS2017 has internal errors when noexcept is used.
71 #define NOEXCEPT
72 #else
73 #define NOEXCEPT noexcept
74 #endif
75 
76 #ifdef __GNUC__
77 #define IGNORE_WARN_INTERFACE(c) virtual ~c() {} // quiet this warning for interfaces. should we do this ?
78 #else
79 #define IGNORE_WARN_INTERFACE(c)
80 #endif // __GNUC__
81 #define IGNORE_WARN_ABSTRACT(c) virtual ~c() {} // quiet this warning for abstract base classes
82 
83  // a structure should be byte packed and not aligned ? use #pragma pack(push,1) as well
84 #if defined(__MINGW32__)
85 #define CATTR_PACKED __attribute__((packed)) // MING compiler uses this to indicate structure packing required.
86 #else
87 #define CATTR_PACKED // _MSC_VER and __GNUC__ use #pragma pack(1) to indicate packing required.
88 #endif
89 
90 #ifdef _MSC_VER
91 #define CATTR_NORETURN __declspec(noreturn)
92 #else // __GNUC__
93 #define CATTR_NORETURN __attribute__((noreturn))
94 #endif
95 
96 #ifdef __GNUC__
97 #define CATTR_CONSTRUCTOR __attribute__((constructor))
98 #define CATTR_DESTRUCTOR __attribute__((destructor))
99 #else
100 #define CATTR_CONSTRUCTOR
101 #define CATTR_DESTRUCTOR
102 #endif
103 
104 // Allow some method to be deprecated. warn the user to change to some new version.
105 #ifdef __GNUC__
106 #define CATTR_DEPRECATEDAT(versionNumber, alternative) __attribute__((deprecated))
107 #define CATTR_DEPRECATED __attribute__((deprecated))
108 #elif _MSC_VER >= 1400
109 #define CATTR_DEPRECATEDAT(versionNumber, alternative) __declspec(deprecated("[" #versionNumber "] This function is now deprecated. Please use '" #alternative "' instead."))
110 #define CATTR_DEPRECATED
111 #else
112 #define CATTR_DEPRECATEDAT(versionNumber, alternative)
113 #define CATTR_DEPRECATED
114 #endif // _WIN32 && MSVS2005
115 
116  typedef UINT_PTR HASHCODE_t;
117  typedef UINT32 HASHCODE32_t;
119 
120 };
121 
122 #endif // _INC_GRAYCORE
< The main namespace for all Core functions.
Definition: GrayCore.cpp:14
const HASHCODE_t k_HASHCODE_CLEAR
not a valid index.
Definition: GrayCore.h:118
UINT_PTR HASHCODE_t
could hold a pointer converted to a number? maybe 64 or 32 bit ? same as size_t.
Definition: GrayCore.h:116
UINT32 HASHCODE32_t
always 32 bits.
Definition: GrayCore.h:117