【发布时间】:2019-03-03 18:58:06
【问题描述】:
得到这个结构:
typedef struct {
unsigned long index;
void(*function)();
} program;
当我尝试访问第二个字段时,我得到了这个:
error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token in program.callNext = next
下一个是之前声明的函数:
void next() {
// code
}
编辑:
完整代码:
typedef unsigned char bool;
#define true 1
#define false 0
void next() {
//useless code
}
typedef void(*function)();
typedef struct {
unsigned long index;
bool running;
function callNext;
} program;
program shell;
shell.running = true;
shell.index = 0;
shell.callNext = next;
gcc 无法识别 bool 类型,所以我添加了它
【问题讨论】:
-
你有一个名为
program的变量吗? -
prog.c:9:5: error: unknown type name ‘bool’ -
@melpomene 在编辑段末尾解释
-
错误信息与您发布的任何代码都不匹配。错误为
program.function,但代码为shell.callNext。