Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef P99_IF_H_
00014 # define P99_IF_H_
00015
00021 #include "p99_logical.h"
00022
00057 #define P00_IGNORE(...)
00058 #define P00_IDENT(...) __VA_ARGS__
00059 #define P00_SKIP_
00060 #define P00_CLAUSE1(...) __VA_ARGS__ P00_IGNORE
00061 #define P00_CLAUSE2(...) P00_IDENT
00062
00063 #define P00__IF_CLAUSE(A,B,C,...) C
00064 #define P00_IF_CLAUSE(EXP) P00__IF_CLAUSE(EXP, P00_CLAUSE1, P00_CLAUSE2, ~)
00065 #define P00_IF_NOT_CLAUSE(EXP) P00__IF_CLAUSE(EXP, P00_CLAUSE2, P00_CLAUSE1, ~)
00066
00083 #define P99_IF_EQ(A, B) P00_IF_CLAUSE(P99_PASTE4(P00_IS_,A,_EQ_,B)())
00084
00090 #define P99_IF_NE(A, B) P00_IF_NOT_CLAUSE(P99_PASTE4(P00_IS_,A,_EQ_,B)())
00091
00092 #define P99_IF_GE_0(A) P00_IF_CLAUSE(P99_PASTE4(P00_IS_,A,_GE_,0)())
00093 #define P99_IF_LT_0(A) P00_IF_NOT_CLAUSE(P99_PASTE4(P00_IS_,A,_GE_,0)())
00094
00099 #define P99_IF_GE(A, B) P99_IF_EQ_1(P99_IS_GE(A, B))
00100
00105 #define P99_IF_LE(A, B) P99_IF_EQ_1(P99_IS_LE(A, B))
00106
00111 #define P99_IF_LT(A, B) P99_IF_EQ_1(P99_IS_LT(A, B))
00112
00117 #define P99_IF_GT(A, B) P99_IF_EQ_1(P99_IS_GT(A, B))
00118
00122 #define P99_IF_EQ_0(N) P99_IF_EQ(0, N)
00123
00127 #define P99_IF_EQ_1(N) P99_IF_EQ(1, N)
00128
00132 #define P99_IF_EQ_2(N) P99_IF_EQ(2, N)
00133
00137 #define P99_IF_EQ_3(N) P99_IF_EQ(3, N)
00138
00142 #define P99_IF_EQ_4(N) P99_IF_EQ(4, N)
00143
00144 #define P99_IF_EMPTY(...) P99_IF_EQ_1(P99_IS_EMPTY(__VA_ARGS__))
00145
00158 #define P99_IF_ELSE(...) P99_IF_EQ_0(P99_IS_EQ_0(__VA_ARGS__))
00159
00160 #define P99_IF_void(...) P99_IF_EQ_1(P99_IS_EQ_void(__VA_ARGS__))
00161
00162 #define P99_IF_VOID(...) P99_IF_EQ_1(P99_IS_VOID(__VA_ARGS__))
00163
00164
00165 #define P00_PRAGMA_(STR) _Pragma(STR)
00166 #define P00_PRAGMA(...) P00_PRAGMA_(#__VA_ARGS__)
00167
00175 #define P99_PRAGMA(...) P99_IF_EMPTY(__VA_ARGS__)()(P00_PRAGMA(__VA_ARGS__))
00176
00181 # undef p99_has_builtin
00182 # undef p99_has_feature
00183 # undef p99_has_extension
00184 # undef p99_has_attribute
00185
00186 # define p99_has_builtin(X) (P99_IF_EQ_1(__has_builtin(X))(1)(0) || P99_IF_EQ_1(p00_has_builtin_ ## X)(1)(0)) // Compatibility with non-clang compilers.
00187 # define p99_has_feature(X) (P99_IF_EQ_1(__has_feature(X))(1)(0) || P99_IF_EQ_1(p00_has_feature_ ## X)(1)(0)) // Compatibility with non-clang compilers.
00188 # define p99_has_extension(X) (P99_IF_EQ_1(__has_extension(X))(1)(0) || P99_IF_EQ_1(p00_has_extension_ ## X)(1)(0)) // Compatibility with non-clang compilers.
00189 # define p99_has_attribute(X) (P99_IF_EQ_1(__has_attribute(X))(1)(0) || P99_IF_EQ_1(p00_has_attribute_ ## X)(1)(0)) // Compatibility with non-clang compilers.
00190
00191
00192 #endif