I need to define a struct, let's say
//globalstruct.h
typedef struct _GlobalStruct {
int a, b;
} GlobalStruct
and then use GlobalStruct
wherever I want just by including globalstruct.h
For example:
//test.c
#include globalstruct.h
void test(GlobalStruct *gs){...}
How can I do this?
Regards
----EDIT----
I think I need to clarify a little bit more my question as I'm completely stuck.
//main.c
#include "gstruct.h"
#include "a.h"
#include "b.h"
...
void something(GlobalStruct *gs){...}
.
//gstruct.h
#ifdef gstruct_h
#define gstruct_h
typedef struct _GlobalStruct{
int a, b;
} GlobalStruct;
#endif
.
//a.h
#ifdef a_h
#define a_h
#include "gstruct.h"
GlobalStruct a_something(...);
#endif
.
//a.c
#include "gstruct.h"
#include "a.h"
GlobalStruct a_something(...){...}
.
//b.h
#ifdef b_h
#define b_h
#include "gstruct.h"
GlobalStruct b_something(...);
#endif
.
//b.c
#include "gstruct.h"
#include "b.h"
GlobalStruct b_something(...){...}
.
Is this ok? Because if it is I'm missing something really silly/small/stupid.
BTW, I'm compiling with gcc main.c a.c b.c -o the_thing
---SECOND EDIT----
I just created an online example so you can see it, download it and try it. It's ready-to-compile but it will fail at compilation time.