Я немного запутался относительно предупреждений компилятора, которые я получаю и как их разрешать. Вот ошибки и соответствующие срезы кода:Confusing Предупреждения компилятора
декларация CMDS (соответствующего большинство из них):
23: static char **cmds[] = { cmd0, cmd1, cmd2, cmd3, cmd4 };
24: static int ncmds = sizeof(cmds)/sizeof(cmds[0]);
pipeline.c: In function âexec_nth_commandâ:
pipeline.c:41: warning: declaration of âncmdsâ shadows a global declaration
pipeline.c:24: warning: shadowed declaration is here
pipeline.c:41: warning: declaration of âcmdsâ shadows a global declaration
pipeline.c:23: warning: shadowed declaration is here
41: static void exec_nth_command(int ncmds, char ***cmds)
pipeline.c: In function âexec_pipe_commandâ:
pipeline.c:68: warning: declaration of âncmdsâ shadows a global declaration
pipeline.c:24: warning: shadowed declaration is here
pipeline.c:68: warning: declaration of âcmdsâ shadows a global declaration
pipeline.c:23: warning: shadowed declaration is here
68: static void exec_pipe_command(int ncmds, char ***cmds, Pipe output)
pipeline.c: In function âexec_pipelineâ:
pipeline.c:79: warning: declaration of âncmdsâ shadows a global declaration
pipeline.c:24: warning: shadowed declaration is here
pipeline.c:79: warning: declaration of âcmdsâ shadows a global declaration
pipeline.c:23: warning: shadowed declaration is here
79: static void exec_pipeline(int ncmds, char ***cmds)
pipeline.c:82: warning: ISO C90 forbids mixed declarations and code
82: pid_t pid;
pipeline.c: In function âerr_usageâ:
pipeline.c:141: warning: declaration of âusestrâ shadows a global declaration
pipeline.c:26: warning: shadowed declaration is here
26: static char const usestr[] = "[-f filename]";
141: static void err_usage(char const *usestr)
Я не понимаю, как две разные именованные переменные разных типов могут скрыть друг друга. –
не параметр скрывает переменную области файла, а не наоборот? – user1338
@MarshallTigerus: поскольку одна глобальная переменная назначает другую локальную. – rodrigo