【问题标题】:Error with struct declare ( error: array type has incomplete element type 'struct entry' )结构声明错误(错误:数组类型具有不完整的元素类型'struct entry')
【发布时间】:2021-09-30 03:56:00
【问题描述】:

我有这段代码,我运行它并得到他的错误:

错误:数组类型的元素类型“结构条目”不完整

我尝试解决它并探索相同的错误但失败了

    #ifndef GLOBAL_H
#define GLOBAL_H

#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <getopt.h>

//list of CONSTANTS
#define BSIZE  128
#define NONE   -1
#define EOS    '\0'

#define NUM     256
#define DIV     257
#define MOD     258
#define ID      259
#define DONE    260


//list of prototype function
void init();
int lexan();
int lookup(char s[]);
int insert(char s[], int tok);
void emit(int t,int tval);
void parse();
void expr();
void term();
void factor();
void match(int t);
void error(char* m);

//list of variables
FILE *input, *output, *err;

int tokenval;

int lineno;

int lookahead;

extern struct entry symtable[];

struct entry {
    char *lexptr;
    int token;
};

#endif

我在这一行得到错误:

extern struct entry symtable[];

这是 (global.h) 的代码,其他文件不会出错

【问题讨论】:

    标签: c struct compiler-errors


    【解决方案1】:

    在第一次使用之前移动要放置的结构条目定义。

    struct entry {
        char *lexptr;
        int token;
    };
    
    extern struct entry symtable[];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-10-24
      • 1970-01-01
      • 1970-01-01
      • 2014-12-27
      • 2022-06-25
      • 1970-01-01
      • 2021-02-09
      相关资源
      最近更新 更多