Computing the absolute value of an integer

Blair P. Houghton bph at buengc.BU.EDU
Tue May 8 01:50:10 AEST 1990


In article <12710 at wpi.wpi.edu> oesterle at wpi.wpi.edu (Shawn H. Oesterle) writes:
>In article <8977 at hydra.gatech.EDU> dsrekml at prism.gatech.EDU (Mike Mitten)
>writes:
>>In article <1990May4.121950.22726 at agate.berkeley.edu>
>>c60c-3cf at e260-3c.berkeley.edu (Dan Kogai) writes:
>>>What's wrong with using a macro like the following
>>>#define abs(x) (((x) >= 0) ? (x) : -(x))
>>Won't both of these macros blow up if x is a function such as:
>>	y = abs(foo(bar));
>
>That's right.  That is one thing which I dislike about macros in C.

Macros are a textual facility, not a functional one.

				--Blair
				  "If you want the assembler, you know
				   where to find it. (cf. D. Ritchie.;
				   or was it B. Kernighan?)"



More information about the Comp.lang.c mailing list