Click here to Skip to main content
16,006,535 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Message handler crashing only in release mode Pin
Chris Losinger12-Apr-02 11:30
professionalChris Losinger12-Apr-02 11:30 
GeneralRe: Message handler crashing only in release mode Pin
Jack Handy12-Apr-02 11:46
Jack Handy12-Apr-02 11:46 
GeneralRe: Message handler crashing only in release mode Pin
Chris Losinger12-Apr-02 11:52
professionalChris Losinger12-Apr-02 11:52 
GeneralHelp me explain this directive Pin
moliate12-Apr-02 10:49
moliate12-Apr-02 10:49 
GeneralRe: Help me explain this directive Pin
Christian Graus12-Apr-02 12:50
protectorChristian Graus12-Apr-02 12:50 
GeneralRe: Help me explain this directive Pin
moliate12-Apr-02 14:39
moliate12-Apr-02 14:39 
GeneralRe: Help me explain this directive Pin
Christian Graus12-Apr-02 15:46
protectorChristian Graus12-Apr-02 15:46 
GeneralRe: Help me explain this directive Pin
Paul M Watt12-Apr-02 19:18
mentorPaul M Watt12-Apr-02 19:18 
Basically it is a manipulation in "C" in order to get what we have in C++ where classes are concerned. It looks like IMPL is a way to get the this pointer from an interface pointer.

(&((class *)0)->member == pointer


The NULL pointer is first converted to pointer that is the desired type, and this pointer is compared to the input pointer. If this comparison was not between two pointers that had a typesafe cast, the compiler would throw an error at this point in the compilation.

(&((class *)0)->member == pointer Smile | :) ,Smile | :) ((class *) (((long) pointer) - offsetof (class, member))))

The key to this macro, is the comma after the comparison test, this basically throws away the result of the comparison, the compiler will see this, and consequently throw away this comparison test in the final compiled code. Then the rest of the macro is used to calculate the offset to the instance data for the struct.

So in short, that comparison is a typesafe cast check in "C", that is performed competely at compile time.

Hope this helps!


Checkout my Guide to Win32 Paint for Intermediates
GeneralRe: Help me explain this directive Pin
moliate13-Apr-02 1:56
moliate13-Apr-02 1:56 
General.Net Pin
12-Apr-02 10:48
suss12-Apr-02 10:48 
GeneralRe: .Net Pin
Christian Graus12-Apr-02 12:52
protectorChristian Graus12-Apr-02 12:52 
GeneralWriting mpeg file with DirectX Pin
Martin Laporte12-Apr-02 10:08
Martin Laporte12-Apr-02 10:08 
GeneralLoadImage() for NT (Q264347) and RLE compression Pin
12-Apr-02 9:38
suss12-Apr-02 9:38 
GeneralRe: LoadImage() for NT (Q264347) and RLE compression Pin
Christian Graus12-Apr-02 12:52
protectorChristian Graus12-Apr-02 12:52 
GeneralDemo Program Help Pin
ed112-Apr-02 9:35
ed112-Apr-02 9:35 
GeneralRe: Demo Program Help Pin
Christian Graus12-Apr-02 13:09
protectorChristian Graus12-Apr-02 13:09 
GeneralRe: Demo Program Help Pin
ed115-Apr-02 3:18
ed115-Apr-02 3:18 
GeneralRe: Demo Program Help Pin
Christian Graus15-Apr-02 10:30
protectorChristian Graus15-Apr-02 10:30 
GeneralWhats the deal with IDispatch? - give us a clue!!! Pin
12-Apr-02 8:54
suss12-Apr-02 8:54 
GeneralRe: Whats the deal with IDispatch? - give us a clue!!! Pin
Le centriste12-Apr-02 9:15
Le centriste12-Apr-02 9:15 
GeneralRe: Whats the deal with IDispatch? - give us a clue!!! Pin
12-Apr-02 9:40
suss12-Apr-02 9:40 
GeneralRe: Whats the deal with IDispatch? - give us a clue!!! Pin
Gerald Schwab12-Apr-02 9:42
Gerald Schwab12-Apr-02 9:42 
GeneralRe: Whats the deal with IDispatch? - give us a clue!!! Pin
12-Apr-02 9:51
suss12-Apr-02 9:51 
GeneralRe: Whats the deal with IDispatch? - give us a clue!!! Pin
Gerald Schwab12-Apr-02 9:48
Gerald Schwab12-Apr-02 9:48 
GeneralRe: Whats the deal with IDispatch? - give us a clue!!! Pin
Gerald Schwab12-Apr-02 9:50
Gerald Schwab12-Apr-02 9: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.