typedef枚举相关的错误

时间:2014-04-04 09:58:04

标签: c enums typedef

In file included from /home/epuser/ajayku/final_test/qemu/qemu-1.6.0.ajay /tcg/tcg.h:117:0,

from /home/epuser/ajayku/final_test/qemu/qemu-1.6.0.ajay/exec.c:29:
`/home/epuser/ajayku/final_test/qemu/qemu-1.6.0.ajay/tcg/tcg-op.h:27:1: error: expected` `identifier before ‘int’`

>并且" tcg-op.h"的初始内容文件

int gen_new_label(void);

static inline void tcg_gen_op0(TCGOpcode opc)

{
    *tcg_ctx.gen_opc_ptr++ = opc;
}

static inline void tcg_gen_op1_i32(TCGOpcode opc, TCGv_i32 arg1)
{
    *tcg_ctx.gen_opc_ptr++ = opc;
    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV_I32(arg1);
}

代码" tcg-op.h"正在被" tcg.h"如下

typedef enum {
#define DEF(name, oargs, iargs, cargs, flags) INDEX_op_ ## name,
#include "tcg-op.h"
#undef DEF
 NB_OPS,
} TCGOpcode;

1 个答案:

答案 0 :(得分:0)

当在enum中包含“tcg-op.h”时,所需的“tcg-op.h”内容将复制到枚举中。

tcg-op.h中没有错误,但是当你在enum中包含它时,编译器会对int gen_new_label(void)感到震惊;在枚举中进行并抛出错误。

如果你这样做,它应该有效 -

#include "tcg-op.h"
#define DEF(name, oargs, iargs, cargs, flags) INDEX_op_ ## name,
typedef enum {
         DEF(ARG1, ARG2, ARG3, ARG4, ARG5)
         NB_OPS,
} TCGOpcode;
#undef DEF