编译器提示 “opcode_table undeclared (first use in this function)",为什么?

标签 c

我有这个功能:

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/

相关文章:

c - while循环不起作用?

c - C 数组和素数

c - 查找可用端口以使用 BSD 打开伪终端

c - 在控制台模式下更改/过滤 GDB 输出

c - 如何在文件中写入完整的结构?

C fork() child 被杀死或处于永恒循环中?

c++ - 真的不需要学习C,因为C++包罗万象吗?

c - dreference 一个返回 malloc 指针的函数然后通过 & 传递变量 addres 是否正确?

c - "openSuse and openGL"环境的示例程序

c - 使用 rand() 在 (a,b)、[a,b]、(a,b] 和 [a,b] 上生成均匀分布的 float