I'm trying to use Micosoft's SAL annotation for my project, however I get the following warning, and I don't know why.
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;
}
When I compile using Visual Studio 2008, I get the following warning:
warning C6540: The use of attribute annotations on this function will invalidate all of its existing __declspec annotations
In the file "c1xxast"
What am I doing wrong? If I remove either the _Check_return_
or the __in
, the warning goes away.
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.
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.
The #define
s 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.
You have mixed the two types:
Attribute:
Non-attribute:
Try changing your annotations to use a single type consistently.
This blog post explains a bit more about this.