Expressions in initializers

Dave P. Schaumann dave at cs.arizona.edu
Tue Mar 5 12:39:25 AEST 1991


In article <1991Mar4.144939.8311 at ux1.cso.uiuc.edu> mcdonald at 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 at 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



More information about the Comp.lang.c mailing list