Hello, My project contains several files: main.c routines.c config.h etc. In the main.c I make a structure like:
xdata struct StructUserRec{ BYTE XPIDNr[9]; char UserName[15]; BYTE ContrHour; BYTE ContrMin; BYTE WorkedHour; BYTE WorkedMin; }; xdata struct StructUserRec UserRec[10];
extern struct StructUserRec UserRec[10];
That said, you can hide a large part of the details even in C, if you really think you have to, by means of a pointer to a struct type, whithout giving the definition of that struct. Just to learn: can you show me how to do this in my specific situation, given the examples above?
You can cast pointers to struct types among each other, as long as one struct type is just an extended version of the other. So you can have a "dummy struct type" exported by the header, with all the private data removed from view by a pointer cast: lib.h:
struct dummy { int magic_cookie; };
struct real { int magic_cookie; /* private data: */ double whatever; char lotofstuff[512]; /* ... */ };
foo_func(struct dummy *this) { struct real *real_this = (struct real *) this; real_this->whatever = 5.25; }
"as long as one struct type is just an extended version of the other" Nice trick, never though about this one! Thanks Hans! -- Geert