W8075 Suspicious pointer conversion (C++)

From RAD Studio
Jump to: navigation, search

Go Up to Compiler Errors And Warnings (C++) Index

(Command-line option to suppress warning: -w-sus)

The compiler encountered some conversion of a pointer that caused the pointer to point to a different type.

You should use a cast to suppress this warning if the conversion is proper.

A common cause of this warning is when the C compiler converts a function pointer of one type to another (the C++ compiler generates an error when asked to do that). It can be suppressed by doing a typecast. Here is a common occurrence of it for Windows programmers:

#define STRICT
#include <windows.h>
LPARAM _export WndProc( HWND , UINT , WPARAM , LPARAM );
test() {
   WNDCLASS wc;
   wc.lpfnWndProc = WndProc;  //warning
}

It is suppressed by making the assignment to lpfnWndProc as follows:

wc.lpfnWndProc = ( WNDPROC ) WndProc;