Ответ: chpst

Vladimir Dronnikov dronnikov at gmail.com
Wed Jul 30 19:49:07 UTC 2008


The first method you proposed just moves all those ifdefs outside the
main(). Thus readability conservation law holds.

The second (# and ## macro expansions) is better but preprocessor does
not support directives in macros. So one can not use, say:
#define lim(a,b) \
  #ifdef RLIMIT_##a \
    limit(RLIMIT_##a, limit##b); \
  #else \
    bb_error.....("no support for RLIMIT_" #a); \
  #endif

Thus again no gain :)

I propose two solutions:
1) use generic failure message, e.g. "system does not support this
limit" and check getrlimit return value to trigger that message. No
check for #ifdef RLIMIT_* is performed.

2) compile out options which has no RLIMIT_* defined for them, e.g.
#ifndef RLIMIT_AS then OPT_a is disallowed.

In either case comments (and applying:) are welcome!

--
Vladimir


-- 
Vladimir



More information about the busybox mailing list