[PATCH] hdparm new option parsing
Rob Landley
rob at landley.net
Sat May 6 23:07:29 UTC 2006
On Friday 05 May 2006 8:22 pm, Tito wrote:
> On Friday 5 May 2006 23:16, Rob Landley wrote:
> > What does the "#define PARSE_OPTS_CMD_V2 parse_opts_v2" accomplish,
> > exactly?
>
> It does the same as
>
> #if ENABLE_FEATURE_HDPARM_SOMETHING
> parse_opts_v2(x,y,z);
> #endif
A normal if:
if (ENABLE_FEATURE_HDPARM_SOMETHING) parse_opts_v2(x,y,z);
Should optimize out when the enable macro is a constant 0. So we can use
normal C syntax and have everything checked for validity by the compiler (and
thus not get surprised by build breaks when we toggle a configuration
symbol).
Alas, sometimes you can't do that because, variables are only conditionally
defined (generally structure members), or a function takes a variable number
of arguments depending on how the config symbols go, and then you can use:
USE_FEATURE_HDPARM_SOMETHING(parse_opts_v2(x,y,z);)
Which has the advantage that the knowledge is localized (the use site is where
the decision whether or not to include the functionality is expressed), but
without the line-based preprocessor syntax. It works well with automatic
string concatenation as well. I.E. "thing" "also" becomes "thingalso", thus
you can do "thing" USE_ALSO("also")
Rob
--
Never bet against the cheap plastic solution.
More information about the busybox
mailing list