For the latest documentation on Visual Studio 2017, see Visual Studio 2017 Documentation.
An expression in SAL can be a C/C++ expression provided that it is an expression that does not have side effects—for example, ++, --, and function calls all have side effects in this context. However, SAL does provide some function-like objects and some reserved symbols that can be used in SAL expressions. These are referred to as intrinsic functions.
The following instrinsic function annotations provide general utility for SAL.
|A synonym for the object that is currently being annotated. When the |
|Expresses a situation where the size of a buffer is too complex to represent by using an annotation expression—for example, when it is computed by scanning an input data set and then counting selected members.|
|When it is evaluated in precondition, |
|The C/C++ reserved keyword |
The following intrinsic function annotations enable manipulation of strings. All four of these functions serve the same purpose: to return the number of elements of the type that is found before a null terminator. The differences are the kinds of data in the elements that are referred to. Note that if you want to specify the length of a null-terminated buffer that is not composed of characters, use the
_Nullterm_length_(param) annotation from the previous section.
Using SAL Annotations to Reduce C/C++ Code Defects
Annotating Function Parameters and Return Values
Annotating Function Behavior
Annotating Structs and Classes
Annotating Locking Behavior
Specifying When and Where an Annotation Applies
Best Practices and Examples