Advertisement

错误使用未定义类型的结构体'xxx'及其相关问题

阅读量:

最近我在开发一个小测试程序的过程中,不小心使用gcc进行编译时,结果就报出了错误信息:'error: invalid use of undefined type 'struct xxxx''。

下面是测试程序片段:

#define MAXIMUM_VALUE 256
#define OPTIMIZER_LENGTH_LIMIT 10
typedef struct _OPT_STACK {
char opt[MAXIMUM_VALUE];
int top = -1;
} OPT_STACK;

typedef struct _opdStack
{
int opd[MAX_NUM];
int top;
} opdStack;

struct optStack optSt;
struct opdStack opdSt;

void initOptSt()
{
optSt.top = -1;
}

......

然后gcc的时候报错,指向说

error: invalid use of undefined type 'struct optStack'

optSt.top = -1;

我对内容进行了大致了解,并观察到这是一个"undefined type"问题,在字面意义上讲,并没有明确的定义。然而实际上我已经预先设置了`

全部评论 (0)

还没有任何评论哟~