Click here to Skip to main content
15,914,795 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionOverride lst2 listbox actions in explorer type open file dialog? Pin
Member 14583203-Nov-04 10:40
Member 14583203-Nov-04 10:40 
Generalcustomizing OPENFILENAME - "new" look Pin
peterchen3-Nov-04 10:27
peterchen3-Nov-04 10:27 
GeneralRe: customizing OPENFILENAME - "new" look Pin
Ryan Binns3-Nov-04 18:43
Ryan Binns3-Nov-04 18:43 
GeneralRe: customizing OPENFILENAME - "new" look Pin
David Crow4-Nov-04 3:56
David Crow4-Nov-04 3:56 
GeneralUnion question Pin
Steve Messer3-Nov-04 9:18
Steve Messer3-Nov-04 9:18 
GeneralRe: Union question Pin
David Crow3-Nov-04 9:38
David Crow3-Nov-04 9:38 
GeneralRe: Union question Pin
Steve Messer3-Nov-04 9:45
Steve Messer3-Nov-04 9:45 
GeneralRe: Union question Pin
Henry miller3-Nov-04 10:32
Henry miller3-Nov-04 10:32 
Not quite. Read the other replys.

Each item in the union STARTS at the same place. They are used either when you know that of two different variables only one is needed (but which one is not known in advance), or when you want to use the same data in different ways. In your case, field takes 32 bits, on a 32 bit system. x represents bit 1 of field, y represents bit 2, and space represents 4-6.

if you do:
struct somestruct mystruct;
mystruct.field = 0xa8000000;

than field (dropping the last 24 bits which are all 0) contains the following in binary:
10101000

Therefore
mystruct.x == 1
mystruct.y == 0
mystruct.z == 1
mystrict.space = 2

(Note, double check this, I might have the layout backwards. I cannot remember this unless I'm deep into such code)

Bitfields almost always make your program larger and slower than just using an int. Therefore the only time you normally see them is in networking and hardware. Both are cases where limits in transfer speed or length are far more important that CPU time or memory. It is generally not worth your time to use them elsewhere.

Warning, whenever you see data structures like this, the author knew something about the exact hardware in question! There are dragons lurking for anyone who trys to run this on anything else without a lot of care. If you do not understand what I'm getting at, stick to less advanced programs. Many programers get by without ever needing to deal with bitfiels.

GeneralRe: Union question Pin
Joaquín M López Muñoz3-Nov-04 10:06
Joaquín M López Muñoz3-Nov-04 10:06 
GeneralRe: Union question Pin
Steve Messer3-Nov-04 10:18
Steve Messer3-Nov-04 10:18 
GeneralRe: Union question[modified] Pin
Antony M Kancidrowski4-Nov-04 2:24
Antony M Kancidrowski4-Nov-04 2:24 
GeneralRe: Union question Pin
Steve Messer4-Nov-04 3:42
Steve Messer4-Nov-04 3:42 
Questionis there platform-independent FillMemory function in C/C++!? Pin
clayman873-Nov-04 9:04
clayman873-Nov-04 9:04 
AnswerRe: is there platform-independent FillMemory function in C/C++!? Pin
Joaquín M López Muñoz3-Nov-04 9:15
Joaquín M López Muñoz3-Nov-04 9:15 
AnswerRe: is there platform-independent FillMemory function in C/C++!? Pin
Rick York3-Nov-04 9:15
mveRick York3-Nov-04 9:15 
GeneralRe: is there platform-independent FillMemory function in C/C++!? Pin
clayman873-Nov-04 10:13
clayman873-Nov-04 10:13 
GeneralRe: is there platform-independent FillMemory function in C/C++!? Pin
Joaquín M López Muñoz3-Nov-04 11:02
Joaquín M López Muñoz3-Nov-04 11:02 
GeneralRe: is there platform-independent FillMemory function in C/C++!? Pin
clayman873-Nov-04 10:34
clayman873-Nov-04 10:34 
GeneralRe: is there platform-independent FillMemory function in C/C++!? Pin
Joaquín M López Muñoz3-Nov-04 11:06
Joaquín M López Muñoz3-Nov-04 11:06 
QuestionThe fastest bitmap blitting software? Pin
KellyR3-Nov-04 8:55
KellyR3-Nov-04 8:55 
AnswerRe: The fastest bitmap blitting software? Pin
ThatsAlok3-Nov-04 22:23
ThatsAlok3-Nov-04 22:23 
QuestionTwo files are the same? Pin
peterchen3-Nov-04 8:14
peterchen3-Nov-04 8:14 
AnswerRe: Two files are the same? Pin
Joaquín M López Muñoz3-Nov-04 8:33
Joaquín M López Muñoz3-Nov-04 8:33 
AnswerRe: Two files are the same? Pin
David Crow3-Nov-04 9:01
David Crow3-Nov-04 9:01 
GeneralCSplitterWnd Tab Views Pin
asv3-Nov-04 7:26
asv3-Nov-04 7:26 

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.