An interesting structure!
rj45rt at hotmail.com
Sun Nov 27 23:35:53 MST 2005
I found an interesting thing about the structure. It is defined just like:
for the application software, it may be coded with c and c++. the compiler
is gcc version 3.3.2
Now, the interesting thing arise, for c++ program, the value of
sizeof(STR) is 8, but for c program, it is 12.
I also dump the memory and found the result below:
for C++ program, the memory is A A B X C C C C;
for C programe, the memory is A A B X X X X X C C C C.
A presents Value A, B is value B, and so on, X means adding value by the
compiler. May be the tag. I am not clear.
??? My question is why the value of sizeof(STR) is 8, not 7 for c++ program,
even if I used 'packed' attribute as below?
and for c program, why it is 12, not 10, the default value of sizeof(bool)
is 4 for c compiler.
When I added the __attribute ((__packed__)) the structure definition as
struct __attribute ((__packed__))
for c++ program, the value sizeof(STR) is also 8, not 7; but for c program,
the value changes from 12 to 10. If we check the memory, we will find the
value of memory changes from AABXXXXXCCCC to AABXXXCCCC.
??? My question is why it is not AAXXBXXXCCCC without 'packed' attribute,
why the tag XX was added behind the BXXX compared with the result with
FREE pop-up blocking with the new MSN Toolbar - get it now!
More information about the PLUG