gcc - gcc从stdin读取gnu readline()的编译错误

嗨,大家好,

我用gnu readline库编写了一个名为“ioprogram.c”的小程序,它引用了Internet上的各种文档。但是,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 ioprogram.c -o ioprogram -lreadline -lncurses

https://stackoverflow.com/questions/4968451/

相关文章:

c++ - 有人如何定义数据类型,然后在数据类型定义之后立即在同一文件中包含的其他文件中使用它

c++ - C++中的模板类

c++ - Netbeans 7.0编译器错误

java - 找不到符号—符号: method lastIndexOf(java.lang.Stri

ios - 从GCC 4.2切换到LLVM 2.0时 ''中的 '-std='值无效

c# - 添加动态评级控件时出现奇怪的编译问题

matlab - Matlab mex中状态码2的构建错误

c# - Visual C#中的奇怪编译错误

gcc - C程序编译错误

xcode - 使用Xcode测试为Objective-C++代码库设置单元