C错误:函数和先前声明的冲突类型在这里(不重复)

sco*_*ott 7 c arrays function

为愚蠢的问题道歉.我在stackoverflow上检查了相同错误的所有类似问题,但它没有帮助我理解为什么在以下代码中发生此错误.

我有一个额外的头文件和一个源文件,它包含在主文件中,当我编译时,我收到以下错误.我试图char** argvmain()另一个头文件中定义的另一个函数传递.

#include "include/Process.h"
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv) {
if (argc < 2) {
    printf("Please provide a path to file\n");
    return (EXIT_FAILURE);
}
Process(argv);
Run Code Online (Sandbox Code Playgroud)

Process.h:

#pragma once
extern void Process(char** path);
Run Code Online (Sandbox Code Playgroud)

Process.c:

#include <stdio.h>
#include "../include/Process.h"
#include <stdlib.h>
#include <sys/stat.h>
#include <syslog.h>
#include <sys/types.h>
#include <unistd.h>
void Process(char** path) {
    printf("%s\n", path[1]);
}
Run Code Online (Sandbox Code Playgroud)

它被编译但警告是

./src/Process.c:22:6: error: conflicting types for ‘Process’
 void Process(char** path) {
      ^
./include/Process.h:17:6: note: previous declaration of ‘Process’ was here
 extern void Process(char** path);
  ^
Run Code Online (Sandbox Code Playgroud)

但是,当我将pathfrom 的类型更改char**char*and argv[1]而不是传递时,警告消失argv.

我无言以对为什么发生这种情况是这样,并根据 这个类似的帖子,我尝试添加一个向前声明char** path以上extern void Process(char** path);的在Process.h文件中,但它并没有帮助.

  • 使用时为什么会抛出此错误char** path
  • 我使用时为什么会消失char* path
  • 到目前为止,我能够看到程序正在运行,即使有这个警告.忽略这个警告是否安全?如果没有,它可能会在运行时产生什么影响?

使用gcc版本4.9.2(Ubuntu 4.9.2-10ubuntu13)

谢谢.

M.M*_*M.M 2

尝试将您的自定义包含放在系统包含之后。

自定义包含可能定义了一个干扰系统包含的宏。为了最大限度地降低这种风险,我总是首先放置标准 C 包含,然后是任何操作系统包含,然后是第三方库,然后是我自己的库

理论上自定义包含不应该这样做,系统包含应该只使用保留名称,但实际上这并不总是发生。