Click here to Skip to main content
15,925,255 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: API to get user's home directory Pin
P-Rex28-Jul-04 22:29
P-Rex28-Jul-04 22:29 
GeneralRe: API to get user's home directory Pin
Chintoo72329-Jul-04 1:37
Chintoo72329-Jul-04 1:37 
GeneralRe: API to get user's home directory Pin
David Crow29-Jul-04 3:09
David Crow29-Jul-04 3:09 
GeneralMFC / VisualC++ 7.0 / accelerators problem Pin
28-Jul-04 20:28
suss28-Jul-04 20:28 
Generalregarding TAPI Pin
Kanagu_INDIAN28-Jul-04 17:44
Kanagu_INDIAN28-Jul-04 17:44 
GeneralRe: regarding TAPI Pin
Michael P Butler29-Jul-04 3:28
Michael P Butler29-Jul-04 3:28 
GeneralRe: regarding TAPI Pin
Kanagu_INDIAN29-Jul-04 17:27
Kanagu_INDIAN29-Jul-04 17:27 
GeneralRe: regarding TAPI Pin
Michael P Butler29-Jul-04 22:27
Michael P Butler29-Jul-04 22:27 
GeneralRe: regarding TAPI Pin
kashish846-Oct-04 8:51
kashish846-Oct-04 8:51 
Generala general question Pin
Anonymous28-Jul-04 17:20
Anonymous28-Jul-04 17:20 
GeneralRe: a general question Pin
Johan Rosengren28-Jul-04 19:51
Johan Rosengren28-Jul-04 19:51 
GeneralRe: a general question Pin
Anonymous28-Jul-04 20:15
Anonymous28-Jul-04 20:15 
GeneralRe: a general question Pin
Johan Rosengren28-Jul-04 20:41
Johan Rosengren28-Jul-04 20:41 
GeneralRe: a general question Pin
Anonymous28-Jul-04 21:11
Anonymous28-Jul-04 21:11 
GeneralRe: a general question Pin
Trollslayer29-Jul-04 1:43
mentorTrollslayer29-Jul-04 1:43 
GeneralScrollable window in vertical and honzontal direction Pin
ting66828-Jul-04 16:47
ting66828-Jul-04 16:47 
Generalcall OnDraw() outside View/Doc Pin
birdman6328-Jul-04 16:31
birdman6328-Jul-04 16:31 
GeneralRe: call OnDraw() outside View/Doc Pin
Johan Rosengren28-Jul-04 19:56
Johan Rosengren28-Jul-04 19:56 
GeneralRe: call OnDraw() outside View/Doc Pin
birdman6329-Jul-04 3:42
birdman6329-Jul-04 3:42 
Generalabout dial-in question! Pin
china_yl28-Jul-04 15:21
china_yl28-Jul-04 15:21 
QuestionAnyone care to tell me why this is 24 bytes? Pin
Link260028-Jul-04 14:51
Link260028-Jul-04 14:51 
AnswerRe: Anyone care to tell me why this is 24 bytes? Pin
JimRivera28-Jul-04 15:26
JimRivera28-Jul-04 15:26 
AnswerRe: Anyone care to tell me why this is 24 bytes? Pin
TheDoctor28-Jul-04 15:52
TheDoctor28-Jul-04 15:52 
AnswerRe: Anyone care to tell me why this is 24 bytes? Pin
ssiegel28-Jul-04 17:35
ssiegel28-Jul-04 17:35 
In a word: boundary alignment. ID is an unsigned int and MAJOR, an enum, also defaults to an int datatype. Ints are 4-byte fields that are naturally aligned on four byte boundarys. Therefore the compiler places the int fields on four byte boundarys. Doubles go on an eight byte boundary.

If the struct does not have the fields ordered in descend size of datatypes, (doubles, ints, short ints and finally char/char array), then the compiler silently inserts unreachable filler alignment bytes. Doubles, ints, etc. are boundary aligned to improve register load performance. On certain types of machines fetching unaligned data can cause an execption.

You can use a #pragma to modify the default boundary alighment.

You can see the result of what the compiler has done by generating a listing that details the struct.

Offset length Field
0 10 name
10 2 unreachable filler inserted by the compiler
12 4 ID
16 1 sex
17 3 unreachable filler inserted by the compiler
20 4 major

Total length=24


Sam
AnswerRe: Anyone care to tell me why this is 24 bytes? Pin
SOCM_FP_CPP29-Jul-04 0:33
SOCM_FP_CPP29-Jul-04 0:33 

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.