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
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.
Probably not, since SAL annotations is a meta-language that can help static analysis tools to check the for bug at compile time, I think it might be compiler dependent ( for complex checks at least to some extent ) So you might not have one-way for all of them, but the transition from one to the other is not too complicated
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With