Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!lll-winken!elroy.jpl.nasa.gov!sdd.hp.com!news.cs.indiana.edu!arizona.edu!arizona!dave From: dave@cs.arizona.edu (Dave P. Schaumann) Newsgroups: comp.lang.c Subject: Re: Expressions in initializers Message-ID: <1032@caslon.cs.arizona.edu> Date: 5 Mar 91 02:39:25 GMT References: <17270@crdgw1.crd.ge.com> <760@ajpo.sei.cmu.edu> <1991Mar4.144939.8311@ux1.cso.uiuc.edu> Organization: U of Arizona CS Dept, Tucson Lines: 24 In article <1991Mar4.144939.8311@ux1.cso.uiuc.edu> mcdonald@aries.scs.uiuc.edu (Doug McDonald) writes: >sqrt(2.0) is an expression. It CAN be evaluated at compile time. Perhaps >some people don't want to write compilers that do that (i.e. they are too >lazy), but it most certainly CAN be evaluated. > >Perhaps a different explanation is appropriate? You want to link the whole floating point library to the C compiler? First thing you need to realize is that there is no special, pre-defined function sqrt() in C. (Suprise!!!) The function sqrt lives in a link libarary. As far as the C compiler knows, it's just another user-defined function. So it can't really be evaluated at compile time. That said, sqrt() (or any other linked-in or user defined function) is known at run-time, so you could have static int foo = bar(baz) ; be short-hand for an initialization that gets done before main() is called. This is another kettle of fish entirely, though. -- Dave Schaumann dave@cs.arizona.edu 'Dog Gang'! Where do they get off calling us the 'Dog Gang'? I'm beginning to think the party's over. I'm beginning to think maybe we don't need a dog. Or maybe we need a *new* dog. Or maybe we need a *cat*! - Amazing Stories