https://github.com/saksham-joshi created https://github.com/llvm/llvm-project/pull/138713
# In C language, - the size of "true" and "false" macro is 4 bytes (for x64 arch) - but the size of "bool" (typedef _Bool) is 1 byte. - In order to decrease the memory usage, we can set the size of "true" and "false" macros to 1 byte using explicit typecasting in macro definition. >From db8d4b5b102c9e1cf8d43d108858ede66baea82f Mon Sep 17 00:00:00 2001 From: SAKSHAM JOSHI <social.sakshamjo...@gmail.com> Date: Tue, 6 May 2025 21:37:08 +0530 Subject: [PATCH] FEAT: 1 byte for "true" & "false" - In C language, - the size of "true" and "false" macro is 4 bytes (for x64 arch) - but the size of "bool" (typedef _Bool) is 1 byte. - In order to decrease the memory usage, we can set the size of "true" and "false" macros to 1 byte using explicit typecasting in macro definition. --- clang/lib/Headers/stdbool.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/lib/Headers/stdbool.h b/clang/lib/Headers/stdbool.h index dfaad2b65a9b5..4b81e4ba820d1 100644 --- a/clang/lib/Headers/stdbool.h +++ b/clang/lib/Headers/stdbool.h @@ -22,8 +22,8 @@ */ #elif !defined(__cplusplus) #define bool _Bool -#define true 1 -#define false 0 +#define true ((bool)1) +#define false ((bool)0) #elif defined(__GNUC__) && !defined(__STRICT_ANSI__) /* Define _Bool as a GNU extension. */ #define _Bool bool _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits