[rfc] macros and macro usage

Bernhard Fischer rep.dot.nop at gmail.com
Sun Jun 15 13:58:08 UTC 2008


On Sun, Jun 15, 2008 at 03:08:46PM +0200, walter harms wrote:
>
>
>Cristian Ionescu-Idbohrn wrote:
>> On Sun, 15 Jun 2008, Denys Vlasenko wrote:
>> 
>>> On Saturday 14 June 2008 21:20, Cristian Ionescu-Idbohrn wrote:
>>>> $ egrep _ARPING include/autoconf.h
>>>> #define CONFIG_ARPING 1
>>>> #define ENABLE_ARPING 1
>>>> #define USE_ARPING(...) __VA_ARGS__
>>>> #define SKIP_ARPING(...)
>>>> #define CONFIG_FEATURE_UDHCPC_ARPING 1
>>>> #define ENABLE_FEATURE_UDHCPC_ARPING 1
>>>> #define USE_FEATURE_UDHCPC_ARPING(...) __VA_ARGS__
>>>> #define SKIP_FEATURE_UDHCPC_ARPING(...)
>>>>
>>>> $ egrep _MMU applets/usage.c
>>>> ./applets/usage.c:#define BB_MMU 0
>>>> ./applets/usage.c:#define USE_FOR_MMU(...)
>>>> ./applets/usage.c:#define BB_MMU 1
>>>> ./applets/usage.c:#define USE_FOR_MMU(...) __VA_ARGS__
>>>>
>>>> For consistancy, I would have expected something similar to this instead:
>>>> #define USE_BB_MMU(...) __VA_ARGS__
>>>> #define SKIP_BB_MMU(...)
>>> The point is, SKIP_xxx(foo) is misnamed. It doesn't skip anything.
>>> It includes foo if xxx is not selected.
>>> BTW, USE_ARPING(foo) is misnamed *too*. It's not "using arping",
>>> it's "using foo if arping [is selected]". USE_IF_ARPING would be
>>> more readable.
>> 
>> Yes, you have a point.
>> USE_IF_FEATURE_X and SKIP_IF_FEATURE_X would be better.

I don't think explicitely adding the implied "_IF" buys anything.
>
>assume that:
> skip = ! use
>
>that means you can write:
>	USE_IF_FEATURE(!x)
no, you cannot. Think about e.g.:

/* If not blah, then we have to foo */
SKIP_FEATURE_BLAH(unsigned foo_stuff);

a '!' doesn't help there.
>
>that would reduce the number of macros by one (type).
>
>ntl: your point is correct, we have way to many macros

I disagree. There is USE_ and SKIP_ that use varargs. For bigger blocks
or where it is more readable, there is ENABLE and !ENABLE

I propose you look at TODO instead and pick a random item to take care
of. That would IMHO make more sense :)



More information about the busybox mailing list