Reputation: 51413
I've implemented a virtual List View control. To do so, I need to handle the LVN_GETDISPINFO notification. I've done it like I've always done it in the past:
case WM_NOTIFY: {
auto const& nmhdr { *reinterpret_cast<NMHDR const*>(lParam) };
if (nmhdr.idFrom == IDC_MY_LIST_VIEW && nmhdr.code == LVN_GETDISPINFOW)
{
// ...
The only thing that changed is that I'm using Visual Studio 2019 now. And the document health indicator doesn't like how LVN_GETDISPINFOW
is defined. It's a preprocessor macro (LVN_FIRST-77)
with LVN_FIRST
being (0U-100U)
. That triggers C26454:
Arithmetic overflow: '%operator%' operation produces a negative unsigned result at compile time
The warning is greatly appreciated, just not when it comes out of header files I do not control. I can disable the warning by wrapping the affected code inside a pragma warning(disable:26454)
directive (properly restoring the previous state right after it). This being a macro, however, I need to do this in my code, everywhere I use any of those constants.
That works, sure. But it's tedious. Is there a way to suppress this warning for all constants defined in CommCtrl.h
, without affecting the check for other code?
Upvotes: 3
Views: 512
Reputation: 9700
The following code solves this issue for me with VS2019. You can have a try:
case WM_NOTIFY: {
auto const& nmhdr{ *reinterpret_cast<NMHDR const*>(lParam) };
switch (nmhdr.code)
{
case LVN_GETDISPINFOW:
if (nmhdr.idFrom == IDC_MY_LIST_VIEW)
{
}
break;
default:
break;
}
}
Refer to "LVN_GETDISPINFO notification code".
Upvotes: 1