Edit

Share via


Warning C28285

For function 'function-name', syntax error in 'annotation'

Remarks

The Code Analysis tool reports this warning for syntax errors in the SAL annotation. The SAL parser will recover by discarding the malformed annotation. Double check the documentation for the SAL annotations being used and try to simplify the annotation. You shouldn't use implementation layer annotations such as __declspec("SAL_begin") directly. If you're using that layer, then change them into higher layers such as _In_/_Out_/_Ret_. For more information, see Annotating Function Parameters and Return Values.

Example

The following code generates this warning. The argument (2,n) is malformed and will cause a C28285 warning after the _Out_writes_z_ macro is expanded.

void example_func(_Out_writes_z_((2,n)) char* buffer, int n)
{
    buffer[n] = '\0';
}

The following code remediates this warning by correcting the malformed annotation

void example_func(_Out_writes_z_(n) char* buffer, int n)
{
    buffer[n] = '\0';
}