Cal*_*ner 3 c variables structure initialization
我遇到了C89之后似乎没有通过任何C标准解决的问题,除非提到结构初始化限制已被解除.但是,我使用Open Watcom IDE(用于调试)遇到错误,其中编译器声明初始化程序必须是常量表达式.
这是正在发生的事情的要点.
typedef struct{
short x;
short y;
} POINT;
void foo( short x, short y )
{
POINT here = { x, y }; /* <-- This is generating the error for the compiler */
/* ... */
}
Run Code Online (Sandbox Code Playgroud)
任何想法为什么,或什么标准不允许?