From 9606632e594c94958116127a39e4411888c4a30b Mon Sep 17 00:00:00 2001 From: Kp Date: Sat, 31 May 2008 23:41:59 -0500 Subject: [PATCH] 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. --- lib/silcutil/silctypes.h | 7 +++++++ 1 file changed, 7 insertions(+) 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 */ -- 2.24.0