I'm working on creating a basic shell in C, running into issues when compiling with gcc:
This is the warning from my IDE:
[query] incompatible function pointer types initializing 'const void (*)(char **)' with an expression of type 'void (*)(char **)' [-Wincompatible-function-pointer-types]
This is the error I'm getting when attempting make a pull request with a json test file set up:
grsh.c:28:48: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
const void (*command_functions[]) (char **) = {&exit_shell, &change_directory, &set_path};
^
grsh.c:28:48: note: (near initialization for 'command_functions[0]')
grsh.c:28:61: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
const void (*command_functions[]) (char **) = {&exit_shell, &change_directory, &set_path};
Particular line of code in question:
const void (*command_functions[]) (char **) = {&exit_shell, &cd, &set_path};
I'll be 100%, not exactly sure what the issue here is. The program compiles and runs within Repl.it when running a normal compile command, but runs into issues when attempting to compile with -Werror and -Wall
Would love to get some feedback on how to properly initialize an array of pointers with type char.