00001
00006 #ifndef PP_H
00007 #define PP_H
00008
00009 #if defined(_MSC_VER)
00010 #undef IS_GCC
00011 #define IS_MSVC
00012 #define ppMSVC(x) x
00013 #define ppGCC(x)
00014 #define ppMSGNU(x,y) x
00015
00016 #elif defined(__GNUC__)
00017 #define IS_GCC
00018 #undef IS_MSVC
00019 #define ppMSVC(x)
00020 #define ppGCC(x) x
00021 #define ppMSGNU(x,y) y
00022 #else
00023 #error I have not tested on this platform... add it.
00024 #endif
00025 #ifdef WIN32
00026 #define ppWindows(x) x
00027 #define ppNotWindows(x)
00028 #define ppWindowsElse(x,e) x
00029 #else
00030 #define ppWindows(x)
00031 #define ppNotWindows(x) x
00032 #define ppWindowsElse(x,e) e
00033 #endif
00034
00035
00039 #define ppCastPtr(type) (type)(void*)
00040
00044 #define ppNULL
00045 #define ppVOID
00046
00050 #define ppCM ,
00051
00055 #define ppLP (
00056
00060 #define ppRP )
00061
00066 #define ppEat(p)
00067
00073 #define ppEat2(p1,p2)
00074
00079 #define ppToken(d) d
00080
00085 #define ppTokStr(d) _ppTokStr(d)
00086
00090 #define ppConcat(a,b) _ppConcat(a,b)
00091
00095 #define ppConcat3(a,b,c) _ppConcat3(a,b,c)
00096
00100 #define ppConcat4(a,b,c,d) _ppConcat4(a,b,c,d)
00101
00105 #define ppConcat5(a,b,c,d,e) _ppConcat5(a,b,c,d,e)
00106
00110 #define ppConcat6(a,b,c,d,e,f) _ppConcat6(a,b,c,d,e,f)
00111
00117 #define ppScr(label) ppConcat(label,__LINE__)
00118 #define ppScr2(root,label) ppConcat3(root,label,__LINE__)
00119
00120
00121
00122
00123 #define _ppTokStr(d) _ppTokStra(d)
00124 #define _ppTokStra(d) #d
00125 #define _ppConcat(a,b) _ppConcata(a,b)
00126 #define _ppConcata(a,b) a ## b
00127 #define _ppConcat3(a,b,c) _ppConcat3a(a,b,c)
00128 #define _ppConcat3a(a,b,c) a ## b ## c
00129 #define _ppConcat4(a,b,c,d) _ppConcat4a(a,b,c,d)
00130 #define _ppConcat4a(a,b,c,d) a ## b ## c ## d
00131 #define _ppConcat5(a,b,c,d,e) _ppConcat5a(a,b,c,d,e)
00132 #define _ppConcat5a(a,b,c,d,e) a ## b ## c ## d ## e
00133 #define _ppConcat6(a,b,c,d,e,f) _ppConcat6a(a,b,c,d,e,f)
00134 #define _ppConcat6a(a,b,c,d,e,f) a ## b ## c ## d ## e ## f
00135
00136
00140 #ifdef __cplusplus
00141 #define ppC_CPP(c,cpp) cpp
00142 #define ppCPP(cpp) cpp
00143 #define ppC(c)
00144 #else
00145 #define ppC_CPP(c,cpp) c
00146 #define ppCPP(cpp)
00147 #define ppC(c) c
00148 #endif
00149
00154 #define ppRaw(rawcooked,raw) ppConcat(ppRAW_,rawcooked)(raw)
00155 #define ppRAW_raw(raw) raw
00156 #define ppRAW_cook(raw)
00157 #define ppCooked(rawcooked,cook) ppConcat(ppCOOK_,rawcooked)(raw)
00158 #define ppCOOK_raw(cook)
00159 #define ppCOOK_cook(cook) cook
00160 #define ppRawCooked(rawcooked, raw, cook) ppConcat(ppRAW_COOK_,rawcooked)(raw,cook)
00161 #define ppRAW_COOK_raw(raw,cook) raw
00162 #define ppRAW_COOK_cook(raw,cook) cook
00163
00167 #if defined(CTL_UNIT) || defined(STL_UNIT)
00168 #define ppForUnit(p) p
00169 #else
00170 #define ppForUnit(p)
00171 #endif
00172
00173
00174 #ifndef offsetof
00175
00181 #if defined(__GNUC__) && defined(__cplusplus)
00182
00183 #define offsetof(s,m) (((size_t)&(((s *)4)->m))-4)
00184 #else
00185 #define offsetof(s,m) ((size_t)&(((s *)0)->m))
00186 #endif
00187 #endif
00188
00189 #ifndef dereference
00190
00197 #define dereference(s,m,p) ((s *)((size_t)(p) - offsetof(s,m)))
00198 #endif
00199
00200 #endif