rl_replace_line 函数无效

发布于 2025-01-18 08:21:14 字数 1199 浏览 0 评论 0原文

我正在尝试运行此代码,但此功能仍然有问题:

# include <unistd.h>
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
# include <limits.h>
# include <errno.h>
# include <readline/readline.h>
# include <readline/history.h>
# include <signal.h>

void sig_handler()
{
    printf ("\n");
    rl_on_new_line();
    rl_replace_line("", 0);
    rl_redisplay();
}
int main()
{
    signal(SIGQUIT, SIG_IGN);
    signal(SIGINT, sig_handler);
    while (1)
    {
        str = readline(BBLU"shell$ "BYEL);
    }
} 

我尝试使用Hombrew安装ReadLine-8.0 当我这样做时:

gcc -Wall -Werror -Wextra -lreadline ./readline-8.0/shlib/libreadline.8.0.dylib main.c

我仍然无法编译该程序。

我尝试做

gcc -wall -werror -werror -wextra main.c -lreadline -l ./readline-8.0/shlib -l ./readline-8.0/

and

gcc -wall -wall -werror-werror- wextra -lreadline -l ./readline-8.0/shlib -l ./readline-8.0/ main.c没有区别。

这是结果:

main.c:50:2:错误:函数'rl_replace_line'的隐式声明在c99 [-werror,-wimplicer-function-unction-declaration] rl_replace_laration] rl_replace_line(“”,0); ^生成1个错误。

I am trying to run this code but I still have an issue with this function:

# include <unistd.h>
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
# include <limits.h>
# include <errno.h>
# include <readline/readline.h>
# include <readline/history.h>
# include <signal.h>

void sig_handler()
{
    printf ("\n");
    rl_on_new_line();
    rl_replace_line("", 0);
    rl_redisplay();
}
int main()
{
    signal(SIGQUIT, SIG_IGN);
    signal(SIGINT, sig_handler);
    while (1)
    {
        str = readline(BBLU"shell$ "BYEL);
    }
} 

I tried to install readline-8.0 using hombrew
and while I'm doing this:

gcc -Wall -Werror -Wextra -lreadline ./readline-8.0/shlib/libreadline.8.0.dylib main.c

I still cannot compile the program.

I tried to do

gcc -Wall -Werror -Wextra main.c -lreadline -L ./readline-8.0/shlib -l ./readline-8.0/

and

gcc -Wall -Werror -Wextra -lreadline -L ./readline-8.0/shlib -l ./readline-8.0/ main.c No difference.

This is the result:

main.c:50:2: error: implicit declaration of function 'rl_replace_line' is invalid in C99 [-Werror,-Wimplicit-function-declaration] rl_replace_line("", 0); ^ 1 error generated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文