You are right. I remember now. The newer macros use reinterpret_cast which fails when the return type differs. The VC6 uses old C cast which doesn't complain.
Printable View
You are right. I remember now. The newer macros use reinterpret_cast which fails when the return type differs. The VC6 uses old C cast which doesn't complain.
Here, reinterpret_cast instead of C-style cast would be "aceeasi Marie cu alta palarie" ("the same Mary with another hat"). Alin, please tanslate a little bit better! :)
I.e. nothing really different.
In fact, newer vesions of MFC use static_cast to avoid nasty troubles because of wrong handler function signatures.
where AFX_PMSG isCode:#define ON_COMMAND(id, memberFxn) \
{ WM_COMMAND, CN_COMMAND, (WORD)id, (WORD)id, AfxSigCmd_v, \
reinterpret_cast<AFX_PMSG> (memberFxn) },
See MSDN:Incorrect Function Signatures May Cause Problems in ReleaseCode:typedef void (AFX_MSG_CALL CCmdTarget::*AFX_PMSG)(void);
I compared C cast of VC6 with reinterpret_cast of newer versions (since VC7 == VS2003 or later). So, it wasn't a valuation of whether static_cast or reinterpret_cast was more suitable to replace a C cast (though I don't like neither of the new ones) but only an attempt to explain why the cast failed in the newer versions.
I don't think that C cast is the same as reinterpret_cast in common but you surely are right regarding casting of function pointers.
First, please keep in mind that even you like or not, reinterpret_cast and static_cast ARE different stuff.
Second, please note that nobody is perfect, then can do mistakes; saying "Ok, I was wrong/made a typo/didn't know" may be appreciated in a greater degree than "I'm always right. My intention was to say someting else but just wanted to foolish you, supid".
Third, before posting please give a breath, think about your answer, and only after that push the "Submit Reply" button.
It makes not the sligthest difference if you do a reinterpret_cast or a static_cast on a function pointer beside that the one may compile while the other doesn't.
So Mary still wears the same hat. Relax. :D
There are significant differences between C++ casting operators. They are not introduced for nothing.
Please read more and stop fluffing threads!