Because the compiler examines all source files for a program, make sure all definitions for a type are the same. See the following listing for an example of conflicting type definitions:
/* fileA.c */ struct a_rec { int i, j; }; a_rec a; /* fileB.c */ struct a_rec { char c; }; /* Conflict with a_rec in fileA.c */ a_rec b;
The following listing shows a suggested solution for C:
/* fileA.c */ struct a1_rec { int i, j; }; a1_rec a; /* fileB.c */ struct a2_rec { char c; }; a2_rec b;
The following listing shows a suggested solution for C++:
/* fileA.c */ namespace { struct a_rec { int i, j; }; } a_rec a; /* fileB.c */ namespace { struct a_rec { char c; }; } a_rec b;