Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C error: initializer element is not constant

Name: Anonymous 2009-02-04 15:43

I have some code that looks like this.


typedef struct {
   void *ptr;
} Foo;

static const size_t a = 1024;
static const size_t b = 1024;
static const size_t c = 1024;
static const size_t d = a * b + c * sizeof(Foo);


On the line declaring and initializing "d", I get the error "error: initializer element is not constant". Now, maybe I'm missing something, but aren't all of the operands there constant, therefore known at compile-time, therefore usable when initializing a constant?

Name: Anonymous 2009-02-04 17:16

What kind of compiler is that?
sizeof() is constant.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List