What is the purpose of __in __out __in_opt __allowed(), how do they work? Should I use similar constructs in my own code?(__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.
这篇关于__in __out __in_opt __allowed() 的目的是什么,它们是如何工作的?我应该在自己的代码中使用类似的结构吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:__in __out __in_opt __allowed() 的目的是什么,它们是如何工作的?我应该在自己的代码中使用类似的结构吗?
基础教程推荐
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 从 std::cin 读取密码 2021-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07