13

I'm trying to get my code as perfect as possible, and I've cleaned up all errors and (other) warnings. I'm left with these two:

Warning C28253  Inconsistent annotation for 'WinMain': _Param_(2) has 'SAL_null(__no)' on this instance.
Warning C28252  Inconsistent annotation for 'WinMain': _Param_(2) has 'SAL_null(__maybe)' on the prior instance.

Here is my WinMain function

int CALLBACK WinMain( _In_ HINSTANCE hInstance, _In_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nCmdShow );

Why is my second paramater HINSTANCE hPrevInstance not annotated correctly despite it being ripped straight from MSDN with the _In_ info?

J. Doe
  • 208
  • 1
  • 4
  • 13

1 Answers1

17

It is because the hPrevInstance argument actually has the _In_opt_ annotation rather than just _In_.

1201ProgramAlarm
  • 32,384
  • 7
  • 42
  • 56
SoronelHaetir
  • 14,104
  • 1
  • 12
  • 23
  • 2
    MSDN fails me again D: – J. Doe Dec 24 '17 at 06:08
  • 2
    I ended up looking at the declaration in winbase.h to make sure I got it right, I knew it was optional (and in fact in win32 and win64 hPrevInstance will always be null) but wasn't sure of the exact annotation. – SoronelHaetir Dec 24 '17 at 06:25
  • 1
    Luckily, the MSDN no longer shows [*any* SAL annotations](https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-winmain), so at least it won't show the wrong ones. Now it just claims it were using the `__clrcall` calling convention. Sigh. The amount of damage that .NET has done to Windows as a native developer platform is far beyond apprehension. – IInspectable Jul 07 '21 at 14:24