Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!ucbvax!dog.ee.lbl.gov!elf.ee.lbl.gov!torek From: torek@elf.ee.lbl.gov (Chris Torek) Newsgroups: comp.lang.c Subject: Re: Expressions in initializers Message-ID: <10592@dog.ee.lbl.gov> Date: 5 Mar 91 01:03:16 GMT References: <17270@crdgw1.crd.ge.com> <760@ajpo.sei.cmu.edu> <1991Mar4.144939.8311@ux1.cso.uiuc.edu> <17294@crdgw1.crd.ge.com> Reply-To: torek@elf.ee.lbl.gov (Chris Torek) Organization: Lawrence Berkeley Laboratory, Berkeley Lines: 25 X-Local-Date: Mon, 4 Mar 91 17:03:17 PST In article <17294@crdgw1.crd.ge.com> volpe@camelback.crd.ge.com (Christopher R Volpe) writes: >"The square root of two" can be evaluated at compile time, but "sqrt(2.0)" >is an invocation of a function. How is the compiler supposed to know >what sqrt is? I could have in another file: > >double sqrt(double x) >{ > return x - 1.0; >} Not in ANSI C (at least, not if you `#include '; I am not sure about the case where you do not include the standard header). Compilers can of course define their own languages and allow static double root2 = sqrt(2.0); but someone writing ANSI C should assume neither this nor that writing double sqrt(double x) { return x - 1.0; } will work. -- In-Real-Life: Chris Torek, Lawrence Berkeley Lab EE div (+1 415 486 5427) Berkeley, CA Domain: torek@ee.lbl.gov