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

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -