Click here to Skip to main content
16,013,082 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralTutorial for Visual C++ .NET 2003 Pin
Rylogy21-Nov-04 9:37
Rylogy21-Nov-04 9:37 
QuestionSTL fstream brakedown in VS .NET? Pin
Robert Bielik21-Nov-04 9:08
Robert Bielik21-Nov-04 9:08 
AnswerRe: STL fstream brakedown in VS .NET? Pin
Aamir Butt21-Nov-04 20:34
Aamir Butt21-Nov-04 20:34 
GeneralRe: STL fstream brakedown in VS .NET? Pin
Robert Bielik21-Nov-04 20:42
Robert Bielik21-Nov-04 20:42 
GeneralBits; Pin
Bo Hunter21-Nov-04 8:38
Bo Hunter21-Nov-04 8:38 
GeneralRe: Bits; Pin
Neville Franks21-Nov-04 10:13
Neville Franks21-Nov-04 10:13 
GeneralRe: Bits; Pin
Bo Hunter21-Nov-04 12:17
Bo Hunter21-Nov-04 12:17 
GeneralRe: Bits; Pin
Henry miller22-Nov-04 2:48
Henry miller22-Nov-04 2:48 
The other guys code works, and sometimes it is best. However consider the following

#define FOO_MASK 0x01000000 //0000 0001 0000 0000 0000 0000 0000 0000 0000, mask for foo

...

if(my_var && FOO_MASK) {
....


This has the advantage that when I read your code I know instantly you are looking for foo, while the other guys code just gives me (1 >> 28). It takes a moment to realize that he is looking at bit 29, and still gives me no indication of what bit 29 is!

Instead of the above you can also use bitfields:

#pragma pack(1)
struct myStruct {
long foo :28;
long bar :1;
long baz :3;
}
#pragma pack()

...
if(mystrct.bar) {
...

This is compiler and CPU specific, but it works fairly often in the real world, and is more readable.

If you must use the other guys code, please do it in a class, and only in one place. Then comment what is going on so when I come across it 10 years from now I can safely make a change.
QuestionHow to create a bitmap using pixel color information in WindowsCE? Pin
mutpan21-Nov-04 7:52
mutpan21-Nov-04 7:52 
GeneralCreate folder Pin
DanYELL21-Nov-04 5:28
DanYELL21-Nov-04 5:28 
GeneralRe: Create folder Pin
John R. Shaw21-Nov-04 5:52
John R. Shaw21-Nov-04 5:52 
GeneralRe: Create folder Pin
Renjith Ramachandran21-Nov-04 7:56
Renjith Ramachandran21-Nov-04 7:56 
GeneralRe: Create folder Pin
ThatsAlok21-Nov-04 17:32
ThatsAlok21-Nov-04 17:32 
GeneralCapture and CHANGE ip packets Pin
kydfru21-Nov-04 3:22
kydfru21-Nov-04 3:22 
GeneralRe: Capture and CHANGE ip packets Pin
benjymous21-Nov-04 22:50
benjymous21-Nov-04 22:50 
QuestionWhat to replace macro in C/C++? Pin
Link260021-Nov-04 2:32
Link260021-Nov-04 2:32 
AnswerRe: What to replace macro in C/C++? Pin
Jörgen Sigvardsson21-Nov-04 2:38
Jörgen Sigvardsson21-Nov-04 2:38 
GeneralRe: What to replace macro in C/C++? Pin
Ryan Binns21-Nov-04 17:48
Ryan Binns21-Nov-04 17:48 
GeneralRe: What to replace macro in C/C++? Pin
Jörgen Sigvardsson21-Nov-04 21:22
Jörgen Sigvardsson21-Nov-04 21:22 
AnswerRe: What to replace macro in C/C++? Pin
John R. Shaw21-Nov-04 5:46
John R. Shaw21-Nov-04 5:46 
GeneralRe: What to replace macro in C/C++? Pin
Link260021-Nov-04 14:04
Link260021-Nov-04 14:04 
GeneralRe: What to replace macro in C/C++? Pin
Ryan Binns21-Nov-04 18:04
Ryan Binns21-Nov-04 18:04 
GeneralRe: What to replace macro in C/C++? Pin
Don Clugston21-Nov-04 19:11
Don Clugston21-Nov-04 19:11 
GeneralPostMessage Doesn't work with ALT Pin
Hany Grees Ayoub21-Nov-04 2:22
Hany Grees Ayoub21-Nov-04 2:22 
GeneralRe: PostMessage Doesn't work with ALT Pin
ThatsAlok21-Nov-04 17:50
ThatsAlok21-Nov-04 17:50 

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.