-
November 3rd, 2017, 11:08 AM
#1
MFC Message maps
Is it possible to use MFC's message mapping macros without Microsoft's extensions to the C++ language?
I'm having some troubles, for example with Clang:
Code:
error: call to non-static member function without an object argument
ON_MESSAGE(WM_UPDATEUISTATE, OnUpdateUIState)
^
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.11.25503\atlmfc\include\afxmsg_.h
expanded from macro 'ON_MESSAGE'
(memberFxn)) },
^
-
November 3rd, 2017, 03:05 PM
#2
Re: MFC Message maps
What do you mean by "without Microsoft's extensions to the C++ language"?
Is your project a MFC one or not?
Victor Nijegorodov
-
November 4th, 2017, 01:08 PM
#3
Re: MFC Message maps
Yes, it's a MFC project and it compiles with the Visual C++ compiler.
However, I'd like to use Clang-Tidy on the code base. It requires that the code can be parsed by the Clang compiler, but it only succeeds if the message maps are removed.
So, the message maps depend on some non-standard or non-portable feature? Looking for an explanation...
Last edited by TubularX; November 4th, 2017 at 01:11 PM.
-
November 4th, 2017, 01:18 PM
#4
-
November 4th, 2017, 03:46 PM
#5
Re: MFC Message maps
"Clang-Tidy is a clang-based C++ linter tool. Its purpose is to provide an extensible framework for diagnosing and fixing typical programming errors, like style violations, interface misuse, or bugs that can be deduced via static analysis."
So, it's just analyzing the source code. It doesn't try to link anything. It doesn't try to build an executable.
If MFC is C++ standard conformant, I don't understand why the treatment differs in the message map macro.
-
November 7th, 2017, 09:29 AM
#6
Re: MFC Message maps
Check if OnUpdateUIState has the corect prototype. If is mapped by using ON_MESSAGE macro, it must be
Code:
afx_msg LRESULT OnUpdateUIState(WPARAM wParam, LPARAM lParam);
Also, is not bad to replace
Code:
ON_MESSAGE(WM_UPDATEUISTATE, OnUpdateUIState)
with
Code:
ON_MESSAGE(WM_UPDATEUISTATE, &CYourClassName::OnUpdateUIState)
Or, a little bit better, use (class) wizard which correctly maps WM_UPDATEUISTATE using ON_WM_UPDATEUISTATE macro, preventing programmers' mistakes.
And BTW: Visual Studio has its own built-in code analysis support (have a look at "Analyze/Run Code Analysis" menu).
-
November 8th, 2017, 06:29 PM
#7
Re: MFC Message maps
Originally Posted by TubularX
Yes, it's a MFC project and it compiles with the Visual C++ compiler.
However, I'd like to use Clang-Tidy on the code base. It requires that the code can be parsed by the Clang compiler, but it only succeeds if the message maps are removed.
So, the message maps depend on some non-standard or non-portable feature? Looking for an explanation...
You can install the MFC source code by changing your VS setup. Then you can drill down into the MFC message map macros and have a look for yourself.
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
|