Re: Hiding a warning?
Re: Hiding a warning?
- Subject: Re: Hiding a warning?
- From: Randy Croucher <email@hidden>
- Date: Tue, 24 Feb 2004 09:37:26 -0800
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'
And I have no solution for that, because it is the macro that has the
address of the member function OnCreate embedded in it. There is no
way for it to know what the class name is without changing the macro to
where you have to specify it (not really an option). I don't mind
changing the guts of the macro, just not the parameters. The compiler
does know what to do, and it does work, it just gives me these 1000+
warnings.
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 } \
}; \
I wish the warnings had a warning number so you could disable
individual ones easily. I think that this new ISO standard for this
causes a big kink in some of these macros that I use extensively. I
hope it doesn't change from a warning to an error any time soon. I get
no complaints out of CodeWarrior or Visual C++, but they may be behind
on the standard.
Thanks,
Randy
_______________________________________________
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.