Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site umcp-cs.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxl!houxm!vax135!cornell!uw-beaver!tektronix!hplabs!hao!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.lang.c Subject: Re: C pre-processor and ANSI standard Message-ID: <8214@umcp-cs.UUCP> Date: Sun, 9-Sep-84 18:46:15 EDT Article-I.D.: umcp-cs.8214 Posted: Sun Sep 9 18:46:15 1984 Date-Received: Fri, 14-Sep-84 08:25:01 EDT References: <572@calgary.UUCP> Organization: U of Maryland, Computer Science Dept., College Park, MD Lines: 37 I always parenthesize my min/max #define's. The big problem with those is that they still generate side effects twice. (But hey!, that's what macros are all about!) As for a macro to put out N spaces, how about: #define spaces(n) \ if (1) { \ register int _youwouldntusethisid = (n); \ while (--_youwouldntusethisid >= 0) \ putchar(' '); \ } \ else This gets around the if (expr) spaces(expr); else ... (dangling else) problem. Now your only trap is writing foo() { spaces(6) bar(); } (a missing semicolon makes unreachable code). Unfortunately, this gives lint indigestion (``constant in conditional context''). -- In-Real-Life: Chris Torek, Univ of MD Comp Sci (301) 454-7690 UUCP: {seismo,allegra,brl-bmd}!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@maryland