Skip to content

Stop warning on reinterpret_cast. #578

Closed

Description

@AraHaan

The code check seems to annoyingly warn me about using reinterpret_cast on Some Windows Types defined in Windows.h that no other C++ casts that I know of (other than C style casts) work on.

Also there are a few types in Windows.h that none of C++'s casts work on forcing C style casts (I am using the lastest Windows 10 SDK on Windows 7 SP1 x64 Build 7601).

A piece of example code that annoy me on code checking:

struct WNDDATA {
	HWND m_hWnd;
	LRESULT m_OrigWndProc;
	BOOL m_Subclassed;
};
WNDDATA g_Window;

LRESULT CALLBACK SCWinProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) {
	switch(uMsg) {
		case WM_DESTROY: {
			SetWindowLongPtr(g_Window.m_hWnd, GWL_WNDPROC, (LONG)g_Window.m_OrigWndProc);
			break;
		}
		case WM_CLOSE: {
			SetWindowLongPtr(g_Window.m_hWnd, GWL_WNDPROC, (LONG)g_Window.m_OrigWndProc);
			break;
		}
		case WM_SYSCOMMAND: {
			switch (wParam) {
				case SC_SCREENSAVE:
				case SC_MONITORPOWER:
				return 0;
			}
			break;
		}
		default:
			break;
	}
	return CallWindowProc((WNDPROC)g_Window.m_OrigWndProc, hWnd, uMsg, wParam, lParam);
}

BOOL SubClassWindowProc(VBTrpSetup_t &setup) {
	g_Window.m_hWnd = setup.GameHWND;
	g_Window.m_OrigWndProc = GetWindowLongPtr(g_Window.m_hWnd, GWL_WNDPROC);
	if (SetWindowLongPtr(g_Window.m_hWnd, GWL_WNDPROC, (LONG)SCWinProc) == g_Window.m_OrigWndProc) {
		g_Window.m_Subclassed = TRUE;
	}
	else {
		g_Window.m_Subclassed = FALSE;
	}
	return g_Window.m_Subclassed;
}

Activity

  1. neilmacintosh commented on Nov 14, 2017

    @neilmacintosh
    Contributor

    Hi AraHaan, this looks like you are referring to CppCoreCheck - the tool that enforces the Core Guidelines that ships with Visual Studio. Unfortunately, this is not the right place to report issues with that tool - this is the repository for the Guidelines Support Library.

    I happen to be the right person to complain to, but I don't have any way of communicating back to you (as this issue will get closed).

    Can I suggest that to report issues like this, you can use the Visual Studio feedback mechanisms. One option to write to us at [email protected]. Alternatively, you can follow these steps: https://docs.microsoft.com/en-us/visualstudio/ide/how-to-report-a-problem-with-visual-studio-2017.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions