Messages in this thread | | | Date | Sun, 10 Jan 1999 01:05:17 +0000 | From | Jamie Lokier <> | Subject | Re: useful exercise |
| |
Pros 1. Some errors spotted earlier in the development process.
2. Both #ifdef and #if forms will not warn if you mis-spell the symbol, but #if has the advantage that _eventually_, a mis-spelling warning is likely to be added to the compiler.
3. The "always defined" form is more flexible, because you have the option of using `#if X', `if (X)' or even using X in an expression, e.g. `X ? a : b', `X && blah_blah'.
Cons
1. Some things will optimise worse if you use `if' -- e.g., if an `if (0)' branch takes the address of a variable, that will still suppress some optimisations of that variable even when the branch is optimised away. However, I'm don't think that's all that common, and GCC can always be tweaked in the long run if it is worth doing.
2. Compilation might take longer because more code is compiled. Then again, the fact that more code is compiled means more errors are found.
3. There's a lot of existing code; if CONFIG_FOO were changed to be defined always, the existing code would compile differently without warning. (This is why C_FOO makes sense).
Many things can't be done with `if', such as conditional declarations, conditional compilation of functions etc. So you need `#if C_FOO' in some places, or keep both symbols and stick with `#ifdef CONFIG_FOO'.
I personally prefer #if X and if (X), because it is more flexible. It's unusual for a config option to make a lot of difference to the amount of code compiled in a single file, so that's not so important.
-- Jamie
- 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/
| |