[clang] FEAT: one byte for "true" & "false" (PR #138649)
via cfe-commits
cfe-commits at lists.llvm.org
Tue May 6 00:29:01 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: SAKSHAM JOSHI (saksham-joshi)
<details>
<summary>Changes</summary>
### 1 byte is enough for bool
- In C programming language,
- the size of **"true"** and **"false"** macros is 4 byte and size of macro "bool" (typedef of _Bool) is 1 byte.
- By this simple change, we can set the size of "true" and "false" to 1 byte.
- This change will decrease the memory usage made by using true & false macros in C.
---
Full diff: https://github.com/llvm/llvm-project/pull/138649.diff
1 Files Affected:
- (modified) clang/lib/Headers/stdbool.h (+2-2)
``````````diff
diff --git a/clang/lib/Headers/stdbool.h b/clang/lib/Headers/stdbool.h
index dfaad2b65a9b5..e9142327f0ffd 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
``````````
</details>
https://github.com/llvm/llvm-project/pull/138649
More information about the cfe-commits
mailing list