0
HI,大家好,GCC編譯錯誤來從標準
我寫一個小程序,名爲「ioprogram.c」,用GNU readline庫,在互聯網上闖民宅的各種文檔閱讀。但是,gcc報告了以下錯誤。我的問題是什麼?
#include <readline/readline.h>
#include <stdio.h>
int main()
{
char* c = readline("");
int len = strlen(c);
for(int i=0; i<len; i++)
{
printf("%c", *(c+i));
fflush(stdout);
}
free(c);
}
GCC錯誤:
In file included from /usr/include/readline/readline.h:37,
from ioprogram.c:1:
/usr/include/readline/rltypedefs.h:65: error: expected ‘)’ before ‘*’ token
In file included from ioprogram.c:1:
/usr/include/readline/readline.h:416: error: expected ‘)’ before ‘*’ token
/usr/include/readline/readline.h:532: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
/usr/include/readline/readline.h:533: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
/usr/include/readline/readline.h:555: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
/usr/include/readline/readline.h:823: error: expected specifier-qualifier-list before ‘FILE’
ioprogram.c: In function ‘main’:
ioprogram.c:7: error: ‘for’ loop initial declaration used outside C99 mode
先感謝您的任何意見。
代碼編譯構建我,我看到你的代碼沒有語法錯誤,但你得到的錯誤提示有一個。請提供您使用的gcc版本,以及您如何編譯代碼。請記住,您需要鏈接到readline庫(「 - lreadline」)。 – gamen 2011-02-11 11:36:30