3 ms·
The inline keyword does not tell the compiler to copy and paste the function body into the caller. This is a misconception. It has semantic differences with whe
by emerged 9y ago
The inline keyword does not tell the compiler to copy and paste the function body into the caller. This is a misconception. It has semantic differences with where functions can be defined without causing duplicate symbol definitions. That is all.
Forced inline, on the other hand, is telling the compiler to copy and paste the function body. This will not always improve performance because code has interactions with the processor and memory/cache which make things more complicated.
- ot 9y ago> That is all. Did you read the article?
- imtringued 9y agoI assume adding "inline" in front of a function declaration without actually defining it in the same compilation unit doesn't result in inlining. If this is true the article is wrong and the only important aspect about inline is how it affects the linker.
- spc476 9y agoIt may very well depend upon the tool chain. The Solaris C compiler/linker can inline external functions (a previous developer at my company relied upon that behavior when writing code), but that's the only one I'm familiar with that behavior.