#ifdef or #if defined?
One of my co-workers discovered an interesting item in the #ifdef/#ifndef entry of the help files for Microsoft Visual C++ 2005:
These directives are provided only for compatibility with previous versions of the language. The defined( identifier ) constant expression used with the #if directive is preferred.
(Update: The same statement is in the help file for Visual C++ 2003. I don’t know about Visual C++ 6.0, the version immediately prior to the 2003 release.)
Preferred by whom? And why?
The two are practically identical in use, and I tend to use both — “#if defined” is good for testing multiple things on a single line (combined with && or ||), “#ifdef” is more concise when you only need to test one thing (which is usually the case). So what’s the reason to “prefer” one over the other? A ‘net search doesn’t turn up any indication of one.
Microsoft doesn’t control either the C or C++ standards, so they can’t remove #ifdef from them. They also can’t unilaterally remove it from the compiler without irritating practically all of their customers (which they really can’t afford to do any further). Where do they get off claiming that one is “preferred”? It sounds to me like the kind of playground-bully attitude that Microsoft has become infamous for.