|
-
January 14th, 2011, 02:58 PM
#16
Re: Error when converting VC 6 project
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.
-
January 15th, 2011, 08:30 AM
#17
Re: Error when converting VC 6 project
 Originally Posted by itsmeandnobodyelse
The newer macros use reinterpret_cast which fails when the return type differs.
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.
Code:
#define ON_COMMAND(id, memberFxn) \
{ WM_COMMAND, CN_COMMAND, (WORD)id, (WORD)id, AfxSigCmd_v, \
reinterpret_cast<AFX_PMSG> (memberFxn) },
where AFX_PMSG is
Code:
typedef void (AFX_MSG_CALL CCmdTarget::*AFX_PMSG)(void);
See MSDN:Incorrect Function Signatures May Cause Problems in Release
Last edited by ovidiucucu; January 15th, 2011 at 08:50 AM.
-
January 17th, 2011, 12:17 PM
#18
Re: Error when converting VC 6 project
 Originally Posted by ovidiucucu
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 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.
-
January 17th, 2011, 02:07 PM
#19
Re: Error when converting VC 6 project
 Originally Posted by itsmeandnobodyelse
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.
Last edited by ovidiucucu; January 17th, 2011 at 02:18 PM.
-
January 17th, 2011, 05:42 PM
#20
Re: Error when converting VC 6 project
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.
-
January 18th, 2011, 02:01 AM
#21
Re: Error when converting VC 6 project
 Originally Posted by itsmeandnobodyelse
So Mary still wears the same hat. Relax. 
There are significant differences between C++ casting operators. They are not introduced for nothing.
Please read more and stop fluffing threads!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|