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

标签 gcc compiler-errors stdout stdin 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

关于gcc - gcc从stdin读取gnu readline()的编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4968451/

相关文章:

c - Makefile,clang OK,gcc错误

node.js - NodeJS : How to read stdout and stderr of a child process spawned by an explicitly spawned process?

node.js - 将标准输出重定向到文件 nodejs

shell - 更改 Perl 6 的 $*OUT 是否会更改子进程的标准输出?

gcc - Android NDK 独立工具链的“配置”失败

c - malloc 如何在多线程环境中工作?

c - 单行注释宏扼杀了 gcc

compiler-errors - 错误: Attempt to give DATA in type-declaration

c++ - 当我尝试通过mingw将CMake与SFML库一起使用来编译项目时出错

c++ - 过载 - 不在范围内