为什么在对 AfxWinInit 的调用中我收到警告 C6309?

发布于 2024-09-14 09:10:28 字数 292 浏览 2 评论 0原文

在进行一些静态代码分析时,我发现了一个奇怪的问题。在这样的调用中:

if(!AfxWinInit(moduleHandle,NULL,::GetCommandLine(),0)

我在第二个参数处收到警告 C6309 (C6309:参数 2 为空:它不符合 AfxWinInit 的函数规范)

文档说,对于 Win32 应用程序,第二个参数必须为 NULL,因此问题是:

a) 我的代码、AfxWinInit 声明或静态代码分析出了什么问题?

提前致谢!

while doing some static code analysis I've found a weird one. On a call like this one:

if(!AfxWinInit(moduleHandle,NULL,::GetCommandLine(),0)

I get the warning C6309 at the second parameter (C6309: argument 2 is null: it does not adhere to function specification of AfxWinInit)

Docs say that for Win32 applications the second parameter must be NULL so the questions is:

a) What's wrong, my code, the AfxWinInit declaration or the static code analysis?

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

慈悲佛祖 2024-09-21 09:10:28
    friend BOOL AFXAPI AfxWinInit(_In_ HINSTANCE hInstance, _In_ HINSTANCE hPrevInstance,
            _In_z_ LPTSTR lpCmdLine, _In_ int nCmdShow);

在我看来这是错误的,第二个参数应该被注释为_In_opt_。来自SAL 注释文档:

可选选项
描述缓冲区本身是否是可选的。这些注释可以应用于参数层、返回值层或前/后层中的值。

  • (没有任何)
    指向缓冲区的指针不能为 NULL。
  • 选择_
    指向缓冲区的指针可能为 NULL。在取消引用之前将对其进行检查。
    friend BOOL AFXAPI AfxWinInit(_In_ HINSTANCE hInstance, _In_ HINSTANCE hPrevInstance,
            _In_z_ LPTSTR lpCmdLine, _In_ int nCmdShow);

That looks wrong to me, the 2nd argument should have been annotated as _In_opt_. From the SAL Annotations documentation:

Optional Option
Describes if the buffer itself is optional. These annotations can be applied to values in the Parameters layer, Return Value layer, or Pre / Post layer.

  • (none)
    The pointer to the buffer must not be NULL.
  • opt_
    The pointer to the buffer might be NULL. It will be checked before being dereferenced.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文