P99
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
p99_if.h
Go to the documentation of this file.
00001 /* This may look like nonsense, but it really is -*- mode: C -*-             */
00002 /*                                                                           */
00003 /* Except of parts copied from previous work and as explicitly stated below, */
00004 /* the author and copyright holder for this work is                          */
00005 /* (C) copyright  2010-2012 Jens Gustedt, INRIA, France                      */
00006 /*                                                                           */
00007 /* This file is free software; it is part of the P99 project.                */
00008 /* You can redistribute it and/or modify it under the terms of the QPL as    */
00009 /* given in the file LICENSE. It is distributed without any warranty;        */
00010 /* without even the implied warranty of merchantability or fitness for a     */
00011 /* particular purpose.                                                       */
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      /* !P99_IF_H_ */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines