Comment Re:D is a regression (Score 0) 386
You don't need a preprocessor to have conditionally compiled code.
Yes, you do.
Because programmers make mistakes and "crazy_new_untested_code.c" may include everything from normal software bugs to syntax errors.
A preprocessor is the only way to ignore syntax errors.
C# supports your use-case (producing different code depending on symbols being defined)
Don't lie. The use case was:
the program will still compile and work just fine, no matter what crazy things the new guy who was hired to program "crazy_new_untested_code.c" does.
If the guy checks in some syntax error in C#, it will no longer compile. End of story.
With a preprocessor you can be absolutely SURE that some disabled code does not influence your program. And if the programmer only has write access to "crazy_new_untested_code.c" he does not even have a theoretical possibility of breaking it.
I have not seen any supposed "replacements" of preprocessors that can do that. These "replacements" are full of unrealistic assumptions straight from the ivory tower. (for example your assumption that all code that is checked in is syntactically correct)
The preprocessor makes code harder to understand, very hard to parse, and makes things like refactoring tools, static analysis tools, etc. much harder than they should be.
Preprocessor-code is much easier to understand than C++ templates. (Yes, I admit it - I have once looked at these template programming and I have long since forgotten about C++ templates) In fact the basic #ifdef structure is straightforward.
Another use-case:
typedef struct {
one int;
#ifdef GREATFEATURE
two int;
#endif
} mystructure;
In that case mystructure will be just as big as actually needed. Can you easily provide the same functionality with C++ templates? Probably not, you probably have to check some book and forum to come up with the code - if it's possible at all, which I'm not sure.
And that is the reason why C is still king for embedded software.