Conversation
For those interested in the 'combinatorial explosion of min()/max() macro' thing slowing down kernel builds, witness the horrors :))

https://lore.kernel.org/all/CAHk-=wjPr3b-=dshE6n3fM2Q0U3guT4reOoCZiBye_UMJ-qg1A@mail.gmail.com/
1
17
33

@ljs
"our complex type-checking min() macro ends
up making it horrible"

What is the fix for that? I mean what would be the right fix, not necessarily whatever stopgap is planned for the moment.

Does this call for a new preprocessor feature, or what?

2
0
0
@dougmerritt you can't expect anything from compilers in any short or medium term.

Solution would ideally be a revert of the series that overcomplicated, but that's not possible as people rely on the relaxed conditions now.

A possible solution is to drop the complexity for cases where the number doesn't strictly have to be const (cases like array size) and use the more complicated version there and only there, or maybe a dumber macro, and then simplify the other cases.

I have proposed this, we'll see :)

There's a series that improves the situation but does even more complicated things and it's causing build bot failures and Linus isn't a fan so not sure that's the answer.

Personally I hate this added complexity and how vulnerable we are here to subtle bugs so advocate for the simple solution.
0
0
1

@dougmerritt @ljs The answer clearly is adding constexpr from C++ to C so you don't have to do that shit in the preprocessor as recursive expansion.

0
0
1