microsoft C considered stupid

Rick Genter rgenter at BBN-LABS-B.ARPA
Tue Jun 24 00:11:12 AEST 1986


     Actually, the defined() preprocessor function does provide a convenience
over #ifdef in one specific case:

	#if defined(VAX730) || defined (VAX750) || defined (VAX780)
		< code which is included when any of the three symbols
		  are defined >
	#endif /* defined ... */

This is a royal pain to accomplish with #ifdef:

	#undef KLUDGE
	#ifdef VAX730
	#define KLUDGE
	#endif /* def VAX730 */

	#ifdef VAX750
	#define KLUDGE
	#endif /* def VAX750 */

	#ifdef VAX780
	#define KLUDGE
	#endif /* def VAX780 */

	#ifdef KLUDGE
		< code which is included when any of the three symbols
		  are defined >
	#endif /* def KLUDGE */

Alternatively, you have to include the code three times.

					- Rick
--------
Rick Genter 				BBN Laboratories Inc.
(617) 497-3848				10 Moulton St.  6/506
rgenter at labs-b.bbn.COM  (Internet new)	Cambridge, MA   02238
rgenter at bbn-labs-b.ARPA (Internet old)	linus!rgenter%BBN-LABS-B.ARPA (UUCP)



More information about the Comp.lang.c mailing list