CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 21 of 21
  1. #16
    Join Date
    Oct 2009
    Posts
    577

    Smile 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.

  2. #17
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: Error when converting VC 6 project

    Quote Originally Posted by itsmeandnobodyelse View Post
    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.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  3. #18
    Join Date
    Oct 2009
    Posts
    577

    Smile Re: Error when converting VC 6 project

    Quote Originally Posted by ovidiucucu View Post
    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.

  4. #19
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: Error when converting VC 6 project

    Quote Originally Posted by itsmeandnobodyelse View Post
    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.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  5. #20
    Join Date
    Oct 2009
    Posts
    577

    Smile 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.

  6. #21
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: Error when converting VC 6 project

    Quote Originally Posted by itsmeandnobodyelse View Post
    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!
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured