I have a .c file which has code for functions, and a .h file that sets up the function prototypes so they can be accessed from other files, but they are in conflict.
Here is the error I get:
file.c:111: error: ‘Function’ redeclared as different kind of symbol
file.h:16: error: previous declaration of ‘Function’ was here
In file.c:
#include "file.h"
...
void开发者_如何学Go *Function(const char *filename) {
...
}
In file.h:
typedef void (*Function)(const char *filename);
Thanks in advance!
You're creating typedef of a function pointer instead of a prototype. Your declaration says that variable of type Function
is a pointer to a function returning nothing and accepting a const char*
.
I think what you really want in the .h file is this:
void *Function(const char *filename);
精彩评论