Click here to Skip to main content
15,911,646 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Edit box selection color Pin
Ganesh_T13-Feb-06 22:16
Ganesh_T13-Feb-06 22:16 
GeneralRe: Edit box selection color Pin
Naveen13-Feb-06 22:27
Naveen13-Feb-06 22:27 
GeneralRe: Edit box selection color Pin
Rage14-Feb-06 2:22
professionalRage14-Feb-06 2:22 
GeneralRe: Edit box selection color Pin
ThatsAlok14-Feb-06 22:00
ThatsAlok14-Feb-06 22:00 
Questionsize of Objects Pin
Subramaniam s.V.13-Feb-06 20:09
Subramaniam s.V.13-Feb-06 20:09 
AnswerRe: size of Objects Pin
Cedric Moonen13-Feb-06 20:23
Cedric Moonen13-Feb-06 20:23 
GeneralRe: size of Objects Pin
Subramaniam s.V.13-Feb-06 20:38
Subramaniam s.V.13-Feb-06 20:38 
GeneralRe: size of Objects Pin
Cedric Moonen13-Feb-06 21:25
Cedric Moonen13-Feb-06 21:25 
I had a deeper look at that and I think I was a little bit wrong in my first answer.
First, the purpose of having structure alignment is for optimizing the speed. It is faster to get the data at once rather (so, contained in the same 8 bytes block starting at an index multiple of 8) than needing to get it in two operations (get the first part that is contained in the previous memory block from the second part).
Thus, for 32 bits systems, memory blocks are accessed in 8 bytes blocks. Thus, the member will be contained completely in a 8 bytes block.

So, let's take your example:

First, you put your char: 1 byte.

Then you have your integer (4 bytes): there is enough space to put it there so you have 5 bytes

Then, your float (4 bytes): there is not enough space left in the previous memory block so make it start in a new block (and add 3 padding bytes in the previous block). That makes 12 bytes.

The double now (8 bytes): there is not enough in the previous block so padd it with 4 bytes and put the double in a new memory block.

So, in total, that makes 24 bytes.

So, I was wrong in my first post: your member struct alignment is set on 8-bytes boundary (and not 4). And that is more logical because it is the default value.

I hope this is clear. Sorry for my previous post.

GeneralRe: size of Objects Pin
haian244213-Feb-06 22:49
haian244213-Feb-06 22:49 
GeneralRe: size of Objects Pin
Subramaniam s.V.13-Feb-06 22:51
Subramaniam s.V.13-Feb-06 22:51 
GeneralRe: size of Objects Pin
haian244213-Feb-06 23:01
haian244213-Feb-06 23:01 
GeneralRe: size of Objects Pin
Subramaniam s.V.13-Feb-06 23:14
Subramaniam s.V.13-Feb-06 23:14 
GeneralRe: size of Objects Pin
BadKarma13-Feb-06 23:24
BadKarma13-Feb-06 23:24 
GeneralRe: size of Objects Pin
Subramaniam s.V.13-Feb-06 23:29
Subramaniam s.V.13-Feb-06 23:29 
GeneralRe: size of Objects Pin
BadKarma13-Feb-06 23:46
BadKarma13-Feb-06 23:46 
GeneralRe: size of Objects Pin
Subramaniam s.V.14-Feb-06 0:16
Subramaniam s.V.14-Feb-06 0:16 
GeneralRe: size of Objects Pin
sunit514-Feb-06 3:16
sunit514-Feb-06 3:16 
GeneralRe: size of Objects Pin
BadKarma14-Feb-06 3:58
BadKarma14-Feb-06 3:58 
GeneralRe: size of Objects Pin
sunit514-Feb-06 18:06
sunit514-Feb-06 18:06 
GeneralRe: size of Objects Pin
Cedric Moonen14-Feb-06 1:13
Cedric Moonen14-Feb-06 1:13 
GeneralRe: size of Objects Pin
Cedric Moonen14-Feb-06 1:15
Cedric Moonen14-Feb-06 1:15 
Questiona question regarding CStringList Pin
namaskaaram13-Feb-06 19:52
namaskaaram13-Feb-06 19:52 
AnswerRe: a question regarding CStringList Pin
Subramaniam s.V.13-Feb-06 20:40
Subramaniam s.V.13-Feb-06 20:40 
Generalits the same thing! Pin
namaskaaram13-Feb-06 21:00
namaskaaram13-Feb-06 21:00 
GeneralRe: its the same thing! Pin
Subramaniam s.V.13-Feb-06 21:10
Subramaniam s.V.13-Feb-06 21:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.