From 881c495234bd49d7e64204a5d200da13a4d38110 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Fri, 26 Jul 2019 19:28:45 -0500 Subject: [PATCH] Bugfix: type sizes autodetection is not reporting proper sizes Expected sizes are not being returned. Rewrite the logic to get casting to the highest value to work as desired. --- level_0/f_types/c/types.h | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/level_0/f_types/c/types.h b/level_0/f_types/c/types.h index dd250ee..9b71184 100644 --- a/level_0/f_types/c/types.h +++ b/level_0/f_types/c/types.h @@ -123,22 +123,19 @@ extern "C"{ #endif // _di_f_status_ // Defines the maximum size to be supported -// I hope these don't get optimized away and are detected at runtime as a result of the bitwise operator #ifndef _di_f_types_sizes_ - #define f_unsigned_char_size (~(unsigned char) 0) - #define f_unsigned_short_size (~(unsigned short) 0) - #define f_unsigned_int_size (~(unsigned int) 0) - #define f_unsigned_long_size (~(unsigned long) 0) - #define f_unsigned_long_long_size (~(unsigned long long) 0) - #define f_unsigned_double_size (~(unsigned double) 0) - #define f_unsigned_long_double_size (~(unsigned double) 0) - #define f_signed_char_size ((~(unsigned char) 0) / 2) - #define f_signed_short_size ((~(unsigned short) 0) / 2) - #define f_signed_int_size ((~(unsigned int) 0) / 2) - #define f_signed_long_size ((~(unsigned long) 0) / 2) - #define f_signed_long_long_size ((~(unsigned long long) 0) / 2) - #define f_signed_double_size ((~(unsigned double) 0) / 2) - #define f_signed_long_double_size ((~(unsigned double) 0) / 2) + #define f_unsigned_char_size ((unsigned char) -1) + #define f_unsigned_short_size ((unsigned short) -1) + #define f_unsigned_int_size ((unsigned int) -1) + #define f_unsigned_long_size ((unsigned long) -1) + #define f_unsigned_long_long_size ((unsigned long long) -1) + #define f_unsigned_double_size ((unsigned double) -1) + #define f_unsigned_long_double_size ((unsigned double) -1) + #define f_signed_char_size (((unsigned char) -1) / 2) + #define f_signed_short_size (((unsigned short) -1) / 2) + #define f_signed_int_size (((unsigned int) -1) / 2) + #define f_signed_long_size (((unsigned long) -1) / 2) + #define f_signed_long_long_size (((unsigned long long) -1) / 2) #endif // _di_f_types_sizes_ // These should define some types use by stdio -- 1.8.3.1