Re: Hiding a warning?
Re: Hiding a warning?
- Subject: Re: Hiding a warning?
- From: Alastair Houghton <email@hidden>
- Date: Wed, 25 Feb 2004 16:08:40 +0000
On 24 Feb 2004, at 17:37, Randy Croucher wrote:
> Hello again,
>
> I thought I might elaborate on this warning. I would rather fix it
> than hide it.
>
> In the following code snippet:
> BEGIN_MESSAGE_MAP(CMasterView, CHashView)
> ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
> ON_WM_CREATE()
> END_MESSAGE_MAP()
>
> The ON_COMMAND line produces:
> /Users/randycroucher/DualMac105/Master/Master.cpp:171: warning: ISO C++
> forbids taking the address of a bound member function to form a pointer
> to member function. Say `&CMasterView::OnAppAbout'
>
> And could be cured by changing my code to say:
> ON_COMMAND(ID_APP_ABOUT, CMasterView::OnAppAbout)
>
> The ON_WM_CREATE line produces:
> /Users/randycroucher/DualMac105/Master/Master.cpp:172: warning: ISO C++
> forbids taking the address of a bound member function to form a pointer
> to member function. Say `&CMasterView::OnCreate'
I'm quite surprised that compiling MFC code using XCode (or rather GCC)
works at all :-)
Nevertheless, you're going to have to change the macros below:
> Here is what those macros are defined to be:
>
> #define BEGIN_MESSAGE_MAP(theClass, baseClass) \
> const AFX_MSGMAP_ENTRY theClass::_messageEntries[] = \
> { \
>
> #define ON_COMMAND(id, memberFxn) \
> { WM_COMMAND, CN_COMMAND, (WORD)id, (WORD)id, AfxSig_vv,
> (AFX_PMSG)&memberFxn },
>
> #define ON_WM_CREATE() \
> { WM_CREATE, 0, 0, 0, AfxSig_is, \
> (AFX_PMSG)(AFX_PMSGW)(int (AFX_MSG_CALL
> CWnd::*)(LPCREATESTRUCT))&OnCreate },
>
> #define END_MESSAGE_MAP() \
> {0, 0, 0, 0, AfxSig_end, (AFX_PMSG)0 } \
> }; \
Try:
#define BEGIN_MESSAGE_MAP(theClass, baseClass) \
typedef theClass MessageMapCurrentClass__; \
const AFX_MSGMAP_ENTRY theClass::_messageEntries[] = \
{
#define ON_WM_CREATE() \
{ WM_CREATE, 0, 0, 0, AfxSig_is, \
(AFX_PMSG)(AFX_PMSGW)(int (AFX_MSG_CALL CWnd::*) \
(LPCREATESTRUCT))&MessageMapCurrentClass__::OnCreate },
instead of the definitions above.
It should work, provided you only define a single class in each file
(the default if you're creating classes with ClassWizard).
> I wish the warnings had a warning number so you could disable
> individual ones easily.
There are a lot of options that you can pass to GCC to disable
individual warnings or classes of warning. I'm not sure which option
covers this particular warning, but I imagine you'll be able to disable
it somehow.
> I think that this new ISO standard for this
> causes a big kink in some of these macros that I use extensively.
Sorry, but the big kink is caused by Microsoft's antipathy towards the
C++ standard. It's been around for quite a while now, but Microsoft
stated at one point that their opinion was that their users were more
interested in features like WFC (now .NET?) than they were in standards
compliance.
Since their compiler isn't standards compliant, I don't suppose they
feel the need to make MFC standards compliant either. (Yes, I know
they put-out propaganda claiming that they are 98% compliant, but there
are still plenty of problems. In fact, I seem to remember reading
recently that they'd admitted that their compliance claims weren't
accurate.)
> I hope it doesn't change from a warning to an error any time soon.
I think that's unlikely, because it's perfectly obvious what the intent
of the programmer was. It might turn into an error if you specified a
--std= option on the command line, or if you used the -Werror option,
but otherwise I think it's very unlikely to result in an actual error.
Kind regards,
Alastair.
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.