#ifndef PACKAGE__PROG__PRJLIBS__WARN_H #define PACKAGE__PROG__PRJLIBS__WARN_H /* Examine the expression (to generate diagnostics), but don't evaluate it. */ #define WARN_CHK(x) (0? (void)(x): (void)0) /* Trigger a diagnostic if this value is not a value of this type. */ #define WARN_TYPE(type, value) WARN_CHK(*(type*)0=(value)) /* Trigger a diagnostic if this value is not an array of this type. */ #define WARN_ARR(type, value) \ WARN_CHK(*(type (**)[sizeof (value)/sizeof *(value)])0=&(value)) /* Trigger a diagnostic if the expression is true. */ #define WARN_IF(x) \ (WARN_TYPE(unsigned long, x), \ WARN_CHK((struct { char a[(x)? -1: 1]; }*)0)) /* Check the properties of a type or value without triggering a diagnostic. */ #define NOWARN_SIGNED(type) ((type)-1<(type)1) #define NOWARN_UNSIGNED(type) (!IS_SIGNED(type)) #define NOWARN_NEGATIVE(type, value) \ ((type)(value)<(IS_SIGNED(type)? (type)0: (type)(value))) #endif