所以我在头文件(实际上是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’
是因为类型转换吗?
答案 0 :(得分:3)
int(t)
这是一个C ++函数式转换。 C风格的演员使用类型名称旁边的括号:
(int)t