0

I am working on this code:

BOOL CALLBACK bWSStatus(HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
    static int npFlag;

    switch (iMsg)
    {
    case WM_INITDIALOG:

        npFlag = (int *)lParam;//Geht in Ordnung, der Wert auf den der Zeiger lParam zeigt ist für npFlag relevant
...

I am getting this warning Warning C4047 : '=': 'int' differs in levels of indirection from 'int *'. Can someone please explain it?

  • 3
    BTW: whenever you see the warning _'foo' differs in levels of indirection from 'bar'_, you should consider it as an error. – Jabberwocky Dec 13 '19 at 15:50

1 Answers1

4

Translation of the comment by Google is

Okay, the value pointed to by the lParam pointer is relevant for npFlag

It seams you forgot to dereference the pointer.

// add * to dereference the pointer
npFlag = *(int *)lParam;
MikeCAT
  • 73,922
  • 11
  • 45
  • 70
  • I think the `(int*)` cast is unnecessary as `LPARAM` is defined as `typedef unsigned __int3264 ULONG_PTR` in `windows.h`. – Dai Dec 13 '19 at 15:50
  • 2
    @Dai you think wrong, inspite of it's name, `ULONG_PTR` is not a pointer type. – Jabberwocky Dec 13 '19 at 15:51
  • @Dai, It's big enough for a pointer, but not actually pointer. See [WPARAM and LPARAM parameters](https://stackoverflow.com/q/6339793/589924) and the typedef in your very own comment – ikegami Dec 13 '19 at 16:08