1 year ago

#365339

test-img

Abrar

rl_replace_line function is invalid

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.

c

shell

signals

readline

0 Answers

Your Answer

Accepted video resources