03-29-2012 01:30 AM - edited 03-29-2012 01:32 AM
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.
03-29-2012 08:21 AM
C99 only allows this for local definitions within a function, not for global declarations (c99 chapter 6.7.8 paragraph 4).
03-29-2012 02:42 PM
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.