P
puzzlecracker
Please let me know if I solved these ones correctly. thx
32 bit machine:
-----------------
1st block: s, si +padding = 4 bytes
2nd block: j = 4 bytes
3rd block: d+padding = 4 bytes
4th block: i = 4 bytes
-----------------------------------
TOTAL: = 16 bytes
64 bit Machine
----------------
1st block: s,si j+d = 8byte
2nd block i+padding = 8byte
------------------------------
TOTAL: 16 bytes
2)
32 bit machine
--------------
1st block: i = 4 bytes
2rd block: s1, c d = 4 bytes
4th block j = 4 bytes
-----------------------------------
TOTAL: 12 bytes
64 bit Machine
----------------
1st block: i, si c + d = 8 byte
2nd block j = 8 byte
---------------------------------
TOTAL: = 16 bytes
=========================================================
small question: virutal functions, regular fucntions and inline
functions take the same space (ex: 4 bytes or 8 bytes 32 and 64 bits
respectively)? According to alignement rules: compiler is tring to fit
as many variable (data types) as possible in each block for as long as
it fits entirely or else adds padding... is that the correct way of
thinking?
also, is function always represented as a pointer in a struct and
occupies its size?
Thanks...
...Puzzlecracker!
struct A
{
char c;
short int si;
int j;
char d
int i;
};
32 bit machine:
-----------------
1st block: s, si +padding = 4 bytes
2nd block: j = 4 bytes
3rd block: d+padding = 4 bytes
4th block: i = 4 bytes
-----------------------------------
TOTAL: = 16 bytes
64 bit Machine
----------------
1st block: s,si j+d = 8byte
2nd block i+padding = 8byte
------------------------------
TOTAL: 16 bytes
2)
struct B
{
int i;
short int si;
char c;
char d;
int j;
};
32 bit machine
--------------
1st block: i = 4 bytes
2rd block: s1, c d = 4 bytes
4th block j = 4 bytes
-----------------------------------
TOTAL: 12 bytes
64 bit Machine
----------------
1st block: i, si c + d = 8 byte
2nd block j = 8 byte
---------------------------------
TOTAL: = 16 bytes
=========================================================
small question: virutal functions, regular fucntions and inline
functions take the same space (ex: 4 bytes or 8 bytes 32 and 64 bits
respectively)? According to alignement rules: compiler is tring to fit
as many variable (data types) as possible in each block for as long as
it fits entirely or else adds padding... is that the correct way of
thinking?
also, is function always represented as a pointer in a struct and
occupies its size?
Thanks...
...Puzzlecracker!