[rfc] macros and macro usage

Cristian Ionescu-Idbohrn cristian.ionescu-idbohrn at axis.com
Sun Jun 15 08:01:31 UTC 2008


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.

> For MMU, I decided to try to make up better names and see how they will
> stick.

Yes.

> > ...
> >
> > Is applets/usage.c the best place?
>
> Propose another one.

It should be a header file.
Some are autogenerated to include/autoconf.h.
We already have an include/bbconfigopts.h.
How does include/bbconf.h or include/bbdefs.h or already existing
include/busybox.h sound?


Cheers,

-- 
Cristian



More information about the busybox mailing list