Tin*_*ark 2 linux gcc initializer
我尝试使用make文件编译C代码.我收到以下错误:
/home/dev5/src/ermparselex.c:69: error: initializer element is not constant
/home/dev5/src/ermparselex.c:69: error: (near initialization for âyyinâ)
Run Code Online (Sandbox Code Playgroud)
代码段和行号:
65 int yyleng; extern char yytext[];
66 int yymorfg;
67 extern char *yysptr, yysbuf[];
68 int yytchar;
69 FILE *yyin = stdin, *yyout = stdout;
70 extern int yylineno;
71 struct yysvf {
72 struct yywork *yystoff;
73 struct yysvf *yyother;
74 int *yystops;};
75 struct yysvf *yyestate;
76 extern struct yysvf yysvec[], *yybgin;
Run Code Online (Sandbox Code Playgroud)
此代码中的任何位置都未定义stdin
和的值stdout
.我无法从谷歌获得适当的解决方案.知道为什么会出现这个错误吗?
在C中,全局变量只能用常量表达式或字符串文字初始化,而常量表达式的规则比C++中的规则要严格得多.
stdin
并且stdout
是指向全局对象的指针,它们不是常量(在链接时可能不知道地址),因此您不能使用它们来初始化全局变量.
归档时间: |
|
查看次数: |
3773 次 |
最近记录: |