跳至主要內容

Code Expansion: Macro vs Inline Function

(the post is automatically translated by AI) Introduction Macros and inline functions are two techniques for code reuse and expansion. Unlike regular function calls, both avoid the overhead of subroutine push/pop operations at runtime, which can speed up execution. The key difference between them is when the expansion happens: macros are substituted by the preprocessor before compilation, while inline functions are expanded by the compiler during compilation. However, both result in larger binary sizes compared to using regular functions, since the code is duplicated at every call site. ...

October 8, 2022 · 4 min · GanniPiece