Skip to content

[th/signedness-check-minmax] add static assertions to NM_MIN()/NM_MAX()/NM_CLAMP() for mixing signed/unsigned arguments

Thomas Haller requested to merge th/signedness-check-minmax into main

The macros NM_MIN()/NM_MAX()/NM_CLAMP() use typeof() to accept any integer type as argument. Internally, they rely on standard C integral conversions of the <> operators and the ternary operator for evaluating the comparison and the result(type).

That works mostly great. Except, comparing signed and unsigned values in C leads to oddities and the caller should explicitly take care of that.

Add static assertions to check that the compared arguments have the same signedness.

Merge request reports