So I have dipped my toes into source code annotations for C++, but discovered there are many ways to Rome, so to speak.
Examples:
__in
_In_
[Pre(FormatString(Style="printf")] LPCSTR format
- VS2005 SAL Annotations
- VS2010 Using Annotations to Reduce C/C++ Code Defects
- VS2012 Using SAL Annotations to Reduce C/C++ Code Defects
Is there one-microsoft-way to do this?
Microsoft has introduced a new SAL standard (SAL 2.0) starting with Windows 81. SAL 2.0 uses the single underscore style of annotations, such as
_In_opt_among others. Thus, for all new code, the best practice would be to follow the SAL 2.0 style, as slides from Microsoft exhibit.For older code, the general rule of “stay consistent” seems to be the best way to go, but if you feel inclined to update all your annotations, again follow the SAL 2.0 style.
—
1 – SAL 2.0 has actually been around since 2010 (check the date on the linked presentation), but it hasn’t been officially supported externally until Windows 8, to the best of my knowledge.