On Mon, Apr 13, 2009 at 9:15 AM, Peter Stuge peter@stuge.se wrote:
ron minnich wrote:
I think this is one reason the Bell Labs crowd started using: if (preprocessor_symbol == value)
That's the C compilers job, after all ...
The more code I see, the more I agree with them.
I can see the point. But I also think excluding code from compilation is a big feature, especially in firmware.
ah yes, but ... just about any reasonable compiler will do something smart with this: if (0) { ...} or if (1) { ... }.
If fact, romcc would not work at all without these types of optimizations ... and this one is not even that aggressive.
So, since: if (preprocessor_symbol == whatever) { ... }
is equivalent to either if (0) {...} or if (1) {...}
I think it is safe to say there is no loss in code reduction.
If we can do it in a smarter way, that could be good, but on the other hand things can be too smart as well.
What Pike et. al are really saying is "don't have cpp do something that the C compiler can do better and with more error checking".
With which I agree.
The reason I care? Because we've had dead code for several years in that fragment Ronald discovered, and that could have been avoided. Scary!
ron