rl_replace_line 函数无效
我正在尝试运行此代码,但此功能仍然有问题:
# 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论