__in __out __in_opt __allowed() 的目的是什么,它们是如何工作的?我应该在自己的代码中使用类似的结构吗?
其中一些预处理器定义在 WinMain 函数和其他 windows 库函数中.他们的目的是什么?它们是如何工作的?将它们写入您的实现或函数调用是一种好习惯吗?
Some of these Preprocessor definitions are in the WinMain function and other windows library functions. What is their purpose? How do they work? and is it good practice to write them into your implementations or function calls?
我最初的研究表明,它们只是简单地设置为:
My initial research suggests they're simply set up equlivalent to:
#define __in
#define __out
#define __in_opt
意味着它们在预处理器过程中被 nothing 替换.它们只是一种文档方法,没有任何功能吗?
Meaning they get replaced with nothing on the Preprocessor pass. Are they just a documentation method, without any functionality?
如果是这样,我可以看到像这样记录代码的好处.使用 doxygen 之类的东西,您需要写出两次参数名称.所以这在理论上可以帮助减少重复并保持一致性......
If so, I can see the advantage to documenting the code in line like this. With something like doxygen you need to write out the parameter names twice. So this could in theory help reduce duplication, and maintain consistency...
我不知道 __allowed()
应该如何工作.
I have no theory for how __allowed()
is supposed to work.
推荐答案
它们是 Source-code Annotation Language 中的 SAL 注释.微软工具依赖于它.MSDN 库文章在这里.代码分析就是一个很好的例子.另一个完全不相关但受这些注释支持的工具是 Pinvoke Interop Assistant.
They are SAL annotations in the Source-code Annotation Language. Microsoft tooling depends on it. The MSDN Library article is here. A good example is Code Analysis. Another quite unrelated tool, but empowered by these annotations is the Pinvoke Interop Assistant.
相关文章