Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!seismo!topaz!bentley!kwh From: kwh@bentley.UUCP (KW Heuer) Newsgroups: net.lang,net.lang.c Subject: Re: C builtin functions Message-ID: <712@bentley.UUCP> Date: Tue, 15-Apr-86 17:23:43 EST Article-I.D.: bentley.712 Posted: Tue Apr 15 17:23:43 1986 Date-Received: Fri, 18-Apr-86 04:16:23 EST References: <4017@pur-ee.UUCP> Organization: AT&T Bell Laboratories, Liberty Corner Lines: 26 Xref: watmath net.lang:2357 net.lang.c:8589 In article <4017@pur-ee.UUCP> pur-ee!pasm (PASM Parallel Processing Laboratory) writes: > but you can just as correctly write: > sizeof int I've seen compilers that will accept this, but I believe K&R says the parens are necessary when the argument is a datatype (to avoid the ambiguity of e.g. "sizeof char * - 1"). > What the heck is a compile-time function? Real useful - > functions that return constants. Come on now. I can think of two cases, off the top of my head, where a compile-time function makes sense: double log10(x) double x; { return log(x)/log(10.0); } char buf[max(XSIZE,YSIZE)]; It's more efficient for log(10.0) to be evaluated at compile-time, and it's essential for the compiler to know the constant result of max(). In practice, of course, these are handled by a preprocessor constant (for the specific value LOG10 or its reciprocal) and a macro implementation of max (which unfortunately can't also be used as a function in general -- this is a potential argument in favor of builtins?). Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint