什么是__in __out __in_opt __allowed(),他们是如何工作的目的是什么?我应该使用类似的结构在我自己的code? [英] What is the purpose of __in __out __in_opt __allowed(), how do they work? Should I use similar constructs in my own code?

查看:505
本文介绍了什么是__in __out __in_opt __allowed(),他们是如何工作的目的是什么?我应该使用类似的结构在我自己的code?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一些preprocessor定义都在WinMain函数和其他窗口库函数。什么是他们的目的是什么?他们如何工作?而且它是很好的做法,它们写入到您的实现或函数调用?

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?

我的初步研究表明,他们只是简单地设置为equlivalent:

My initial research suggests they're simply set up equlivalent to:

#define __in 
#define __out
#define __in_opt

这意味着他们得到与的没有的在preprocessor通取代。他们只是一个文档的方法,没有任何功能?

Meaning they get replaced with nothing on the Preprocessor pass. Are they just a documentation method, without any functionality?

如果是这样,我可以看到优势,在这样的行记录了code。随着类似的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...

我没有理论如何 __允许()应该工作。

I have no theory for how __allowed() is supposed to work.

推荐答案

他们在源 - code语言的注释SAL注释。微软工具依赖于它。在MSDN Library文章是这里。一个很好的例子是 code分析。另一个相当无关的工具,但这些注解授权是的PInvoke互操作助理。

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(),他们是如何工作的目的是什么?我应该使用类似的结构在我自己的code?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆