F
FTSoJ
On a file A.c I define the structure T1
typedef struct {
int dummy;
int age;
char lastname [128];
char firstname[128];
} T1_user;
On a file B.c I define a strcuture T2
typedef struct {
int id;
int age;
char dummy[256]
} T2_id;
I would like to generate an error during compilation if sizeof (T1)
differ from sizeof(T2).
I tried
#if sizeof(T2_id) != sizeof(T1_user)
#error "Size of T1_user differ from T2_id, compile abort!"
#endif
But it fails on metrowerks as on GCC.
This is a sample, in real T1 from Tn are unions and I would like to
guaranty that interprocess exchange can't lead to buffer overflow if one
Tn type is modified in the future.
Regards,
- François -
typedef struct {
int dummy;
int age;
char lastname [128];
char firstname[128];
} T1_user;
On a file B.c I define a strcuture T2
typedef struct {
int id;
int age;
char dummy[256]
} T2_id;
I would like to generate an error during compilation if sizeof (T1)
differ from sizeof(T2).
I tried
#if sizeof(T2_id) != sizeof(T1_user)
#error "Size of T1_user differ from T2_id, compile abort!"
#endif
But it fails on metrowerks as on GCC.
This is a sample, in real T1 from Tn are unions and I would like to
guaranty that interprocess exchange can't lead to buffer overflow if one
Tn type is modified in the future.
Regards,
- François -