From: Kp Date: Sun, 1 Jun 2008 04:41:59 +0000 (-0500) Subject: Type sanity: add compile time check that integers are of the expected size. X-Git-Tag: silc.server.1.1.12~5^2~2 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=9606632e594c94958116127a39e4411888c4a30b Type sanity: add compile time check that integers are of the expected size. The comments in silctypes.h guarantee that certain types are of particular sizes. Add compile time checks that will fail if these guarantees are not met. --- diff --git a/lib/silcutil/silctypes.h b/lib/silcutil/silctypes.h index 70bc3016..b22c7e77 100644 --- a/lib/silcutil/silctypes.h +++ b/lib/silcutil/silctypes.h @@ -634,4 +634,11 @@ do { \ #endif /***/ +typedef char __check_size1[sizeof(SilcInt8) == 1 ? 1 : -1]; +typedef char __check_size2[sizeof(SilcUInt8) == 1 ? 1 : -1]; +typedef char __check_size3[sizeof(SilcInt16) == 2 ? 1 : -1]; +typedef char __check_size4[sizeof(SilcUInt16) == 2 ? 1 : -1]; +typedef char __check_size5[sizeof(SilcInt32) == 4 ? 1 : -1]; +typedef char __check_size6[sizeof(SilcUInt32) == 4 ? 1 : -1]; + #endif /* SILCTYPES_H */