0
我正在使用野牛和flex构建语法树,并得到一个不兼容的指针类型,我不明白。错误是:具有相同类型的不兼容指针类型
mycompiler.y:89:5: warning: passing argument 1 of ‘addSymbolToTable’ from incompatible pointer type [enabled by default]
symtree.h:57:15: note: expected ‘struct symTableNode *’ but argument is of type ‘struct symTableNode *’
我不明白为什么它抛出一个警告时,当两个结构是相同的类型。
这是头文件:
typedef struct symTable {
varType symbolType; /* Type of Symbol (char,int,array) */
int intValue;
char* charValue;
int size; /* Size of array. Else -1 */
char* id; /* Variable id (name) */
int symDefined;
struct symTable *next;
} symTableNode;
symTableNode* addSymbolToTable(symTableNode* table, varType Type, int intVal, char* charVal, int s ize, char* id);
valType是一个简单的typedef定义枚举。
这里是我的Flex文件中的行:
multparm_types:type ID { addSymbolToTable(globalScope->symbolTable,$1,0,0,0,$2); }
和类型,ID被宣布为:
%type <valType> type
%token <name> ID
%union {
char *token;
struct symTableNode* symbol;
char* name;
int valType;
};