4 ms·
Well, I guess you could have tested whether or not the inline hint is used without looking at any source code at all: just find a suitable example program and s
by kleiba 9y ago
Well, I guess you could have tested whether or not the inline hint is used without looking at any source code at all: just find a suitable example program and see whether the executable changes after you compiled the program with or without any inline hints.
However, this bears the risk of being non the wiser in case your chosen program doesn't produce any differences in the compiled output: you wouldn't know whether it's because the compiler doesn't respect inline or whether the particular program you tried was for some reason not a good choice.
- tonyarkles 9y agoDepending on the simplicity of the program, the compiler may go ahead and inline it anyway!
- classichasclass 9y agoMy takeaway is the keyword's really just a hint anyhow. And that's borne out by the code dive.
- spc476 9y agoI use it to show intent, as functions I mark as inline are those that, pre-C99, would have most likely been a macro. I prefer the inline function over a macro as it prevents a certain class of errors and you get some additional type-checking that macros lack.