[PATCH] Avoid double argument evaluation in MIN and MAX macros

Bartosz Gołaszewski bartekgola at gmail.com
Wed Apr 2 12:20:50 UTC 2014


2014-04-02 13:52 GMT+02:00 Mason <mpeg.blue at free.fr>:
>
> Would it be possible to define MIN and MAX as inline functions?
>
> static inline int MIN(int a, int b) { return a < b ? a : b; }

Macros accept any comparable type, so you would have to have specific
functions for int, unsigned, double etc.

2014-04-02 12:07 GMT+02:00 Denys Vlasenko <vda.linux at googlemail.com>:
> typeof() is GCCism. I am wary of using it unless it's necessary.

# find | egrep "\.[ch]$" | xargs grep "typeof"
./coreutils/sleep.c:    ts.tv_sec = MAXINT(typeof(ts.tv_sec))

Typeof() is already used here and there are many other GCCisms all
over the place anyway.

Best regards,
Bartosz Golaszewski


More information about the busybox mailing list