X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fcheck_type%2Fcheck_type.h;h=77501a95597c3e73396c270d54a8ed53a9defbc4;hb=ed6dd33e06c0e8f1c4dd006e0b70d9f2d6ba6c09;hp=e05236f8f4feb4777e1b01fe3a64c7dc0cc7531d;hpb=650c775ff00cccd03fc84e7789a03c51d9839004;p=ccan diff --git a/ccan/check_type/check_type.h b/ccan/check_type/check_type.h index e05236f8..77501a95 100644 --- a/ccan/check_type/check_type.h +++ b/ccan/check_type/check_type.h @@ -1,3 +1,4 @@ +/* CC0 (Public domain) - see LICENSE file for details */ #ifndef CCAN_CHECK_TYPE_H #define CCAN_CHECK_TYPE_H #include "config.h" @@ -11,7 +12,7 @@ * argument is of the expected type. No type promotion of the expression is * done: an unsigned int is not the same as an int! * - * check_type() always evaluates to 1. + * check_type() always evaluates to 0. * * If your compiler does not support typeof, then the best we can do is fail * to compile if the sizes of the types are unequal (a less complete check). @@ -31,14 +32,14 @@ * arguments are of identical types. No type promotion of the expressions is * done: an unsigned int is not the same as an int! * - * check_types_match() always evaluates to 1. + * check_types_match() always evaluates to 0. * * If your compiler does not support typeof, then the best we can do is fail * to compile if the sizes of the types are unequal (a less complete check). * * Example: * // Do subtraction to get to enclosing type, but make sure that - * // pointer is of correct type for that member. + * // pointer is of correct type for that member. * #define container_of(mbr_ptr, encl_type, mbr) \ * (check_types_match((mbr_ptr), &((encl_type *)0)->mbr), \ * ((encl_type *) \ @@ -51,13 +52,13 @@ #define check_types_match(expr1, expr2) \ ((typeof(expr1) *)0 != (typeof(expr2) *)0) #else -#include "build_assert/build_assert.h" +#include /* Without typeof, we can only test the sizes. */ #define check_type(expr, type) \ - EXPR_BUILD_ASSERT(sizeof(expr) == sizeof(type)) + BUILD_ASSERT_OR_ZERO(sizeof(expr) == sizeof(type)) #define check_types_match(expr1, expr2) \ - EXPR_BUILD_ASSERT(sizeof(expr1) == sizeof(expr2)) + BUILD_ASSERT_OR_ZERO(sizeof(expr1) == sizeof(expr2)) #endif /* HAVE_TYPEOF */ #endif /* CCAN_CHECK_TYPE_H */