Re: useful exercise

J.D. Bakker (bakker@thorgal.et.tudelft.nl)
Fri, 8 Jan 1999 14:59:02 +0100


At 8:27 AM +0100 07-01-1999, kwrohrer@ce.mediaone.net wrote:
>And lo, Tigran Aivazian saith unto me:
>>
>> Then <linux/autoconf.h> will have to contain all the lines like:
>>
>> int config_foo = 1;
>or #define CONFIG_FOO 1, or 0 or 2...
>
>> which means whatever generates it will have to be modified.
>> Also, each config option would waste four bytes of memory, whilst
>> preprocessor #define CONFIG_FOO uses no memory at all.
>> But, apart from that, imho - good idea :)
>#define and if seems the best from a kernel tester's point of view.
>#define and #if seems much better for those who just want to compile
>the damn thing.

Especially because it (using if instead of #if/#ifdef) only works for code
segments that don't rely on conditional elements of a struct, which are not
uncommon in the kernel sources.

Consider:

struct foo {
int bar;
#if CONFIG_FOO_BAZ
int baz;
#endif
};

and:

int init_foo(struct foo *initme)
{
initme->bar = 0;

#if CONFIG_FOO_BAZ
initme->baz = 0;
#endif
}

would work, while:

int init_foo(struct foo *initme)
{
initme->bar = 0;

if(CONFIG_FOO_BAZ) {
initme->baz = 0;
}
}

would generate compile errors if CONFIG_FOO_BAZ is zero, even though the
piece of code would be removed by the optimizer. This means that a simple
search/replacce is out of the question and that kernel development would be
more bothered by this kind of approach than IMHO is necessary.

Sincerely,

Jan-Derk Bakker.

--
Life. In order of importance: food, shelter and a pair of very loud speakers.

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/