奇怪的SAL标注警示 [英] Strange SAL annotation warning

查看:137
本文介绍了奇怪的SAL标注警示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用Micosoft的SAL标注为我的项目,但我得到以下警告,我不知道为什么。

I'm trying to use Micosoft's SAL annotation for my project, however I get the following warning, and I don't know why.

作为一个例子,我创建了一个新的C ++控制台应用程序,并拥有这code:

As an example, I created a new C++ console application, and have this code:

#include <sal.h>

class Whatever
{
public:
    _Check_return_ int Method(__in int number) ;
};

int main()
{
    return 0;
}

当我编译使用Visual Studio 2008,我得到以下警告:

When I compile using Visual Studio 2008, I get the following warning:

警告C6540:此功能的使用属性注释,将会使所有现有__declspec注释

warning C6540: The use of attribute annotations on this function will invalidate all of its existing __declspec annotations

在文件c1xxast

我是什么做错了吗?如果我删除无论是 _Check_ret​​urn _ __在,警告消失。

What am I doing wrong? If I remove either the _Check_return_ or the __in, the warning goes away.

我找不到警告C6550任何引用。然而,相同的文本可以在这里找到: http://msdn.microsoft.com/ EN-US /库/ dd445322.aspx ,但它不是非常有帮助。

I cannot find any reference to the warning C6550. However the same text can be found here: http://msdn.microsoft.com/en-us/library/dd445322.aspx, but it's not very helpful.

推荐答案

这个问题可能是因为你是混合SAL注释类型。虽然说得很清楚MSDN上,有两种类型的SAL注释:属性和......呃......不会

The problem may be because you are mixing SAL annotation types. Although made very clear on MSDN, there are two types of SAL annotation: attribute and ... er ... not.

的#define S IN &LT; sal.h&GT; VC2005使用非属性的版本,并开始下划线后跟一个小写信。较新版本的VC2008扩展到编译器的属性,并开始(和结束)以下划线后跟一个资本信。

The #defines in <sal.h> VC2005 use the non-attribute versions and start with an underscore followed by a lowercase letter. The newer VC2008 versions expand to compiler attributes and start (and end) with an underscore followed by a capital letter.

您已经混合两种类型:

属性:


  • _ _在

  • _Check_ret​​urn _

非属性:


  • __中

  • __ checkReturn

试着改变你的注释坚持使用单一类型的。

Try changing your annotations to use a single type consistently.

本博客文章解释详细了解一下这一点。

This blog post explains a bit more about this.

这篇关于奇怪的SAL标注警示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆