I'm having a bit of trouble trying to get structs to work properly when they are defined in different files. From as far as I can tell, the error is telling me that the struct is being defined two different times. I believe that perhaps I may need to use extern somewhere? I've tried experimenting and looking for help on Google, but to no avail.
Any help at all would be most appreciated, thank you. All four of my files are below.
FILE: Foo.h
typedef struct
{
int number;
} my_struct; // Redefinition; different basic types
FILE: Foo.c
#include "Foo.h"
#include "Bar.h"
#include <stdio.h>
my_struct test;
int main(void)
{
test.number = 0;
DoSomething(&test);
printf("Number is: ", &test.number);
}
FILE: Bar.h
#include "Foo.h"
void DoSomething(my_struct *number);
FILE: Bar.c
#include "Bar.h"
void DoSomething(my_struct *number)
{
number->number = 10;
}