But isn't it bad practice? Like, isn't it seen evil when you often use them? Especially because they are hard to debug? (I can't watch the video currently)
I think it depends, trivial min() and max() style functions are very common and considered acceptable, though I guess you could have been using inline for the last two decades...
The only time I got any serious usage out of preproc functions was writing a driver for an AT-command set cellular modem which involved writing a ton of repetitive code for each AT command.
I think I would prefer this sort of content in wrtten form though, cause I do it so seldom, I always need to look up syntactic specials like 'stringizing' where I even tend to forget the names of the concepts :)
Sure. So? If the compiler feels it's more efficient not to inline, who am I to judge? As far as I know there's nothing keeping the compiler from recognizing repetitive code generated by macros and factoring out into a single assembly routine...
4 Comments
ReakDuck@lemmy.ml · 1 pts · 3y
But isn't it bad practice? Like, isn't it seen evil when you often use them? Especially because they are hard to debug? (I can't watch the video currently)
a2800276@lemmy.world · 3 pts · 3y
I think it depends, trivial
min()andmax()style functions are very common and considered acceptable, though I guess you could have been usinginlinefor the last two decades...The only time I got any serious usage out of preproc functions was writing a driver for an AT-command set cellular modem which involved writing a ton of repetitive code for each AT command.
I think I would prefer this sort of content in wrtten form though, cause I do it so seldom, I always need to look up syntactic specials like 'stringizing' where I even tend to forget the names of the concepts :)
nomadjoanne@lemmy.world · 1 pts · 3y
Isn't
inlinetechnically just a suggestion to the compiler though? It's not necessarily guaranteed to inline it.a2800276@lemmy.world · 2 pts · 3y
Sure. So? If the compiler feels it's more efficient not to inline, who am I to judge? As far as I know there's nothing keeping the compiler from recognizing repetitive code generated by macros and factoring out into a single assembly routine...