How does C struct ignore inner order, for a compiler? -
for example, have 2 struct:
struct type1 { int t; char c; }; struct type2 { char c; int t; };
in stage can c compiler ignore difference in order , settle them same struct? , how?
in stage can c compiler ignore difference in order , settle them same struct? , how?
compiler not ignore order in struct members declared. in fact, structure guarantees members laid out in memory in same order declared in, notwithstanding padding bits inserted when necessary struct alignment. therefore, compiler treat struct type1
, struct type2
different types.
Comments
Post a Comment