“WinMain”的注释不一致

J. *_*Doe 9 c++ windows code-analysis visual-studio

我试图让我的代码尽可能完美,并且我已经清除了所有错误和(其他)警告。我只剩下这两个:

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.
Run Code Online (Sandbox Code Playgroud)

这是我的 WinMain 函数

int CALLBACK WinMain( _In_ HINSTANCE hInstance, _In_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nCmdShow );
Run Code Online (Sandbox Code Playgroud)

为什么我的第二个参数HINSTANCE hPrevInstance没有正确注释,尽管它是直接从 MSDN 中提取的_In_信息?

Sor*_*tir 12

这是因为hPrevInstance参数实际上具有_In_opt_ 注释而不仅仅是_In_.

  • MSDN 再次让我失败 D: (2认同)
  • 我最终查看了 winbase.h 中的声明以确保其正确,我知道它是可选的(事实上在 win32 和 win64 中 hPrevInstance 将始终为 null),但不确定确切的注释。 (2认同)