1 /* need to include STDIO.H for FPRINTF() */
12 static int err_mac_ans;
15 * For functions returning int, when you want an immediate return.
18 /* CHK() fails if (a != SUCCESS) */
21 if( (err_mac_ans = (a)) != SUCCESS ) { \
22 fprintf(stderr,"FAILURE: %s.%d. (%s) returned %d\n",__FILE__,__LINE__, #a, err_mac_ans); \
28 /* AST() fails if (a != 0) */
31 if( (err_mac_ans = (a)) == FALSE ) { \
32 fprintf(stderr, "ASSERT FAILED: %s.%d (%s) returned %d\n",__FILE__,__LINE__, #a, err_mac_ans); \
38 /* like AST(), but return E_CODE instead of the default FAILURE */
39 #define E_AST(a,e_code) \
42 fprintf(stderr,"ASSERT FAILED: %s.%d (%s)\n",__FILE__,__LINE__, #a); \
48 /* like E_AST(), but also fprintfs __VA_ARGS__ */
49 #define M_AST(a,e_code,...) \
52 fprintf(stderr,"ASSERT FAILED: %s.%d (%s) ",__FILE__,__LINE__, #a); \
53 fprintf(stderr, __VA_ARGS__); \
59 /* print a message and return E_CODE */
60 #define M_EXIT(e_code, ... ) \
62 fprintf(stderr,"EXIT: %s.%d ",__FILE__,__LINE__); \
63 fprintf(stderr, __VA_ARGS__ ); \
69 * When you don't want an immedate return, but would rather 'goto Error;'.
70 * These set the local variable RC with the return value before jumping.
75 if( (rc = (a)) != SUCCESS ) { \
76 fprintf(stderr,"FAILURE: %s.%d. (%s)\n",__FILE__,__LINE__, #a); \
84 if( (rc = (a)) == FALSE ) { \
85 fprintf(stderr, "ASSERT FAILED: %s.%d (%s)\n",__FILE__,__LINE__, #a); \
91 #define G_E_AST(a,e_code) \
94 fprintf(stderr,"ASSERT FAILED: %s.%d (%s)\n",__FILE__,__LINE__, #a); \
101 #define G_M_AST(a,e_code,...) \
104 fprintf(stderr,"ASSERT FAILED: %s.%d (%s) ",__FILE__,__LINE__, #a); \
105 fprintf(stderr, __VA_ARGS__); \
112 /* print a message and return E_CODE */
113 #define G_M_EXIT(e_code, ... ) \
115 fprintf(stderr,"EXIT: %s.%d ",__FILE__,__LINE__); \
116 fprintf(stderr, __VA_ARGS__ ); \
123 * And when you only want to print a message
127 if( (a) != SUCCESS ) { \
128 fprintf(stderr,"FAILURE: %s.%d. (%s)\n",__FILE__,__LINE__, #a); \
133 /* AST() fails if (a != 0) */
136 if( (a) == FALSE ) { \
137 fprintf(stderr, "ASSERT FAILED: %s.%d (%s)\n",__FILE__,__LINE__, #a); \