lextestpass.l:384:错误:“int”之前的预期表达式
所以我在头文件(实际上是 y.tab.h 文件)中有这个定义:
typedef enum yytokentype {
TOKEN_UNKNOWN = 1000,
TOKEN_ABBREV = 1001,
TOKEN_AT = 1002,
TOKEN_COMMA = 1003,
TOKEN_COMMENT = 1004,
TOKEN_ENTRY = 1005,
TOKEN_EQUALS = 1006,
TOKEN_FIELD = 1007,
TOKEN_INCLUDE = 1008,
TOKEN_INLINE = 1009,
TOKEN_KEY = 1010,
TOKEN_LBRACE = 1011,
TOKEN_LITERAL = 1012,
TOKEN_NEWLINE = 1013,
TOKEN_PREAMBLE = 1014,
TOKEN_RBRACE = 1015,
TOKEN_SHARP = 1016,
TOKEN_SPACE = 1017,
TOKEN_STRING = 1018,
TOKEN_VALUE = 1019
} token_t;
这是我正在使用的函数的一部分:
static token_t out_token(token_t t)
{
int n;
int temp;
if (1)
{
temp = int(t);
temp = 1000-temp;
(void)printf("this is the value of the array : %d\n",temp);
(void)printf("%d\t%s\t", (int)t, type_name[temp]);
}
但它给了我以下错误:
lextestpass.l:384: error: expected expression before ‘int’
是因为类型转换吗?
So I have this definition in a header file (actually the y.tab.h file):
typedef enum yytokentype {
TOKEN_UNKNOWN = 1000,
TOKEN_ABBREV = 1001,
TOKEN_AT = 1002,
TOKEN_COMMA = 1003,
TOKEN_COMMENT = 1004,
TOKEN_ENTRY = 1005,
TOKEN_EQUALS = 1006,
TOKEN_FIELD = 1007,
TOKEN_INCLUDE = 1008,
TOKEN_INLINE = 1009,
TOKEN_KEY = 1010,
TOKEN_LBRACE = 1011,
TOKEN_LITERAL = 1012,
TOKEN_NEWLINE = 1013,
TOKEN_PREAMBLE = 1014,
TOKEN_RBRACE = 1015,
TOKEN_SHARP = 1016,
TOKEN_SPACE = 1017,
TOKEN_STRING = 1018,
TOKEN_VALUE = 1019
} token_t;
and this is a part of the function that I'm using:
static token_t out_token(token_t t)
{
int n;
int temp;
if (1)
{
temp = int(t);
temp = 1000-temp;
(void)printf("this is the value of the array : %d\n",temp);
(void)printf("%d\t%s\t", (int)t, type_name[temp]);
}
But it gives me the following error:
lextestpass.l:384: error: expected expression before ‘int’
Is it because of the typecasting?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是 C++ 函数风格的转换。 C 风格的转换在类型名周围使用括号:
This is a C++ function-style cast. The C-style cast uses parentheses around the typename: