Re: variable initialization / I'm a n00b



"rjtucke" <rjtucke@xxxxxxxxx> wrote:

Hi all- this is my first post here- just a quick question:

#include <math.h>
double foo = cosh(0.621);
int main() {
return 0;
}

fails with

error: initializer element is not constant

Yes? Initialisers for static-duration objects (i.e., "global" objects,
and "local" objects you've declared using static) must be compile-time
constants, and a function call is not a compile-time constant, even if
all its arguments are.

In addition to telling me what I'm doing wrong, could you please refer
me to an appropriate reference for related questions?

K&R.

Richard
.