[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <48387FE7.2080608@goop.org>
Date:	Sat, 24 May 2008 21:51:51 +0100
From:	Jeremy Fitzhardinge <jeremy@...p.org>
To:	"H. Peter Anvin" <hpa@...or.com>
CC:	Tom Spink <tspink@...il.com>,
	Vegard Nossum <vegard.nossum@...il.com>,
	Sam Ravnborg <sam@...nborg.org>,
	Steve French <smfrench@...il.com>,
	lkml <linux-kernel@...r.kernel.org>
Subject: Re: kernel coding style for if ... else which cross #ifdef
H. Peter Anvin wrote:
> Jeremy Fitzhardinge wrote:
>> Tom Spink wrote:
>>> A thought occurred to me that we may be able to used some preprocessor
>>> magic and do this:
>>>
>>> #define config_defined(x) CFGVAL_## x
>>>
>>> Which means that, if we get Kconfig to produce:
>>>
>>> #define CFGVAL_CONFIG_FOO 0
>>> #define CFGVAL_CONFIG_VALUE_BAR 1
>>> #define CFGVAL_CONFIG_VALUE_BAZ_MODULE 1
>>>
>>> We can use this:
>>>
>>> if (config_defined(CONFIG_FOO) && some_expr) {
>>>    panic("Oh no.");
>>> }
>>
>> Well, in that case you could use Willy's magic hack:
>>
>> #define config_defined(x)      (x - 0)
>>
>> Which isn't a bad alternative to defining a whole pile of new symbols...
>>
>
> That can *strongly* be argued with.
>
> In particular, the use of #ifdef is crap to begin with.  Using #if 
> even for the preprocessor makes it possible to trap misspellings. 
Yes, I'd agree if we were starting from scratch.  But given that we 
can't get rid of CONFIG_* and their dubious semantics, we just have to 
make do.
But typo-detection *would* be very nice: I can never remember if its 
CONFIG_MEMORY_HOTPLUG or CONFIG_HOTPLUG_MEMORY.
    J
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Powered by blists - more mailing lists
 
