Skip to content

Commit 337975e

Browse files
authored
Improve clarity on compile-time optimizations
Clarify the optimization behavior of programs in C.
1 parent d253e8b commit 337975e

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

_posts/2025-11-30-comptime-c-functions.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ Compile-time function execution is great, but what if you're:
99
2. Don't want to use evil C macros.
1010
3. Want generic data structures that work for all types.
1111

12-
The below programs are optimized away by both GCC and Clang, such that only the `printf()` at the end of `main()` is left.
12+
The below programs get optimized away at compile time, such that only the `printf()` at the end of `main()` is left, both with GCC and Clang.
13+
14+
[LTO](https://en.wikipedia.org/wiki/Interprocedural_optimization) should in theory allow GCC and Clang to perform this optimization even when the code is split across several object files, but I haven't tested this.
1315

1416
# Generic Stack
1517

0 commit comments

Comments
 (0)