Error C: conflicting types for function and previous declaration were here (not duplicated)

Apologies for the dumb question. I checked all similar questions for the same error in stackoverflow, but this did not help me understand why this error occurs in the following code.

I have one additional header file and a source file that is included in the main file, and when I compile, I get the following error. I am trying to pass char** argv from main() to another function defined in another header file.

 #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); 

Process.h:

 #pragma once extern void Process(char** path); 

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]); } 

It compiles, but a warning

 ./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); ^ 

However, the warning disappears when I change the path type from char** to char* and pass argv[1] instead of argv .

I don’t know why this happens, and according to this similar post , I tried to add a Process.h declaration for the char** path above the extern void Process(char** path); Process.h file extern void Process(char** path); but that didn't help either.

  • Why does this error occur when using char** path ?
  • Why does it disappear when I use char* path ?
  • Until now, I could see how the program works, even with this warning. Can this warning be ignored? If not, what are the possible effects that can be obtained at runtime?

Using gcc version 4.9.2 (Ubuntu 4.9.2-10ubuntu13)

Thanks.

+7
c function arrays
source share
1 answer

Try adding your order after turning on the system.

It is possible that the user attribute defines a macro that interferes with the system. To minimize the risk of this, I always believe that the C standard includes first, then any OS, then third-party libraries, and then my own.

In theory, the user approach should not do this, and the system includes only the use of reserved names, but in practice this does not always happen.

+1
source share

All Articles