Meaning of __in , __out, __in_opt

前端 未结 2 1836
广开言路
广开言路 2020-12-19 02:13

What is the meaning of these keywords used before variables in a function parameters?

  • __in
  • __out
  • __in_opt
2条回答
  •  半阙折子戏
    2020-12-19 02:46

    As answered by Nercolis, these are SAL annotation attributes. However, these aren't just internal or just for API documentation. The real purpose is for Code Analysis. When you build the project with /analyze compiler option (Project Properties, Code Analysis -> General), these play important role in finding the coding issues.

    For example, if a particular pointer argument says __in then it must not be passed a null pointer. The function will not check for null and may cause SEH. __in_opt argument may be null. When compiler finds some issue, it reports it as a warning. See this article.

提交回复
热议问题