3 ms·
What he's doing seems useful to the project. There's no better time to get it right. I'm just surprised he's willing to expend so much effort communicating inst
by jongraehl 16y ago
What he's doing seems useful to the project. There's no better time to get it right. I'm just surprised he's willing to expend so much effort communicating instead of just fixing the patch.
I noticed that C programmers tend to use macros for things where (possibly non-exported) inline functions would make more sense. Why is that? Are they in the habit of building the OS with all optimizations off? Or is it that they're being used as poor man's generic function?
- wulczer 16y agoYou can't always reply on the compiler inlining your function, and AFAIK there's no portable way of forcing inlining.
- cube13 16y agoThe inline keyword is best thought of as a hint to the compiler, not a command. The compiler is free to ignore the meatbag telling it to inline functions if it chooses to. Macros are substituted in before the compiler, so they are always inlined. EDIT: Hint, not suggestion.
- Someone 16y agoThat is true, but the idea that programmers can use macros to force the compiler to emit optimal code is wrong, too. In the early days of C, that was (almost) true, but those days are over. In theory, a compiler could uninline common code blocks, including macro calls, into functions to decrease object code size and/or working set size, thus speeding up the program (example: functions f and g with inlined function h each take 2 cache lines; without inlining, each of f, g and h fit a single cache line) In practice, using an inline function will give the compiler the opportunity to weigh different objectives (code size, execution speed, debuggability, etc) against each other, and do the better thing.
- abecedarius 16y agoI think it's mostly inertia and culture. Inline functions weren't in the standard till C99.