如何在不收到以下警告的情况下使用gcc编译lex文件?如何删除以下'隐式函数声明'警告?
lex.yy.c: In function `yy_init_buffer':
lex.yy.c:1688: warning: implicit declaration of function `fileno'
lex.l: In function `storeLexeme':
lex.l:134: warning: implicit declaration of function `strdup'
这些是我包括的图书馆。
%{
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
%}
函数yy_init_buffer不在文件中。以下是函数storeLexeme。
int storeLexeme() {
for (int i = 0; i < count; i++) {
char *curr = *(symbolTable + i);
if (strcmp(curr, yytext) == 0) {
return i;
}
}
char *lexeme = (char *)malloc(sizeof(char *));
lexeme = (char *)strdup(yytext);
symbolTable[count] = lexeme;
count++;
return (count - 1);
}
如何删除警告?
//declare the function
int storeLexeme();
//use the function here
或包括其中函数声明的标题:
我更改了flex标签,因为它是关于Adobe flex而不是GNU lex克隆。 – 2012-02-24 08:08:39
什么平台,UNIX或Windows? – paxdiablo 2012-02-24 08:10:02
那些不是'图书馆';他们是'头'。链接中使用库;源代码引用标题。 – 2012-12-05 03:40:15