You are actually creating a myStruct variable in the header file which then is included in both c files. This causes your error.
Define in the .h file:
struct myStruct
{
int a;
int b;
};
If you want it to be global, in ONE of your .c files add:
struct myStruct myStruct;
In the other .c file, add:
extern struct myStruct myStruct;
It would be better not to use a global across .c files if you can help it, and just pass a pointer to myStruct in to the called functions as needed. Also, it would be better to use a different name from the actual structure type. (i.e. don't call both the structure and variable myStruct).
|