Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is _Use_decl_annotations_ meaning

Tags:

c++

c

driver

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

"May be used on a function definition (also known as a function body) in place of the list of annotations in the header. When _Use_decl_annotations_ is used, the annotations that appear on an in-scope header for the same function are used as if they are also present in the definition that has the _Use_decl_annotations_ annotation."

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

like image 939
user3326148 Avatar asked Jun 26 '14 09:06

user3326148


1 Answers

This annotation instructs the static code analysis tool to take the annotations from the declaration when analyzing the definition of a function.

This is useful, for example, when you implement an API that ships as headers and binaries. In this scenario you typically wish to provide the user of the API with the same SAL annotations that the implementation uses. To prevent duplication of annotations, the function declarations in the public header file are decorated with SAL annotations and the private implementation uses _Use_decl_annotations_ to reuse the same annotations for static code analysis.

like image 65
IInspectable Avatar answered Sep 28 '22 15:09

IInspectable