What is the _Use_decl_annotations_ value

I am new to SAL. I want to know what _Use_decl_annotations_ means. I studied MSDN: http://msdn.microsoft.com/en-us/library/jj159529.aspx .

"Can be used to define a function (also known as a function body) instead of a list of annotations in the header. When _Use_decl_annotations_, the annotations that appear in the header in scope for the same function are used as if they were also present in the definition that has _Use_decl_annotations_ annotations. "

However, I just can't get in. When and why should I use it for a function?

+7
c ++ c driver
source share
1 answer

This annotation indicates that the static code analysis tool accepts annotations from the declaration when analyzing a function definition.

This is useful, for example, when implementing an API that comes in the form of headers and binaries. In this case, you usually want to provide the API user with the same SAL annotations that are used in the implementation. To prevent duplication of annotations, function declarations in the common header file are decorated with SAL annotations, and a private implementation uses _Use_decl_annotations_ to reuse the same annotations for static code analysis.

+7
source share

All Articles