我有这个功能:
void run(int PC)
{
int A = 0, op = 0, arg = 0, i = 0;
char *xpress = NULL, *acode = NULL, strarg[CL_ARG_SIZE];
while (1)
{
printf("PC: %03x | A: %03i |", PC, A);
op = data[PC]; arg = data[PC+1];
PC += 2;
for (i=0 ; i<21 ; ++i)
if (op == opcode_table[i].op)
{
acode = opcode_table[i].mnemo;
sprintf(strarg, "0x%x", arg);
xpress = replace(opcode_table[i].instruct, "_", strarg);
break;
}
printf(" %s %x\t| %s \t", acode, arg, xpress);
step();
exec_instruct(op, arg, &A, &PC);
}
}
当我尝试编译我的程序时,出现以下错误:
:103:35: error:‘opcode_table’ undeclared (first use in this function) :103:35: note: each undeclared identifier is reported only once for each function it appears in
我做错了什么?
最佳答案
在您的函数中有三行代码,您在其中使用了数组变量 opcode_table
而没有先声明它。开始于:
if (op == opcode_table[i].op)
关于编译器提示 “opcode_table undeclared (first use in this function)",为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33309696/