You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _posts/2025-11-30-comptime-c-functions.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,13 @@ main:
20
20
ret
21
21
```
22
22
23
+
Here is how it is achieved in C:
24
+
-`static inline` allows inlining across compilation boundaries.
25
+
-`__attribute__((always_inline))` forces the compiler to inline functions.
26
+
- Constant buffer addresses + sizes let the optimizer trace through `memcpy()` calls.
27
+
- All operations become statically analyzable, reducing to constants.
28
+
-`assert()` calls get eliminated when conditions are provably true.
29
+
23
30
[Link-time optimization](https://en.wikipedia.org/wiki/Interprocedural_optimization) should allow GCC and Clang to perform these optimizations even when the code is split across several object files.
0 commit comments