I need to provide the C static library to the client and need to be able to make the structure definition inaccessible. In addition, I need to be able to execute code before the main when initializing the library using a global variable.
Here is my code:
private.h #ifndef PRIVATE_H #define PRIVATE_H typedef struct TEST test; #endif private.c (this should end up in a static library) #include "private.h" #include <stdio.h> struct TEST { TEST() { printf("Execute before main and have to be unavailable to the user.\n"); } int a; // Can be modified by the user int b; // Can be modified by the user int c; // Can be modified by the user } TEST; main.c test t; int main( void ) { ta = 0; tb = 0; tc = 0; return 0; }
Obviously this code does not work ... but show me what I need to do ... Does anyone know how to make this work? I google quite a bit, but can not find the answer, any help would be greatly appreciated.
TIA!
c struct static static-libraries
BobMcLaury
source share