LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

C99 aggregate type non-constant initializers

So if CVI supports C99 non-constant initializers for an aggregate type like a struct, how come I can't do this in CVI 2010:

 

int intfunc (void);

 

typedef struct _myStruct {

  int value;

} myStruct;

 

myStruct  foo  = {intfunc()};

 

function call is a postfix expression and C99 says you can initialize an aggregate type with an expression.

0 Kudos
Message 1 of 3
(3,611 Views)

C99 only allows this for local definitions within a function, not for global declarations (c99 chapter 6.7.8 paragraph 4).

Message 2 of 3
(3,602 Views)

Thanks - yes, I was trying this as a top level variable.  C99 restricts to block scope for variable arrays too so shouldn't be surprised I guess.  Designers didn't want to require elaboration at runtime of top level stuff.

0 Kudos
Message 3 of 3
(3,588 Views)