C++中的_In_是什么

What is _In_ in C++?

本文关键字:是什么 In C++ 中的      更新时间:2023-10-16

我已经搜索了很多,但没有找到有用的结果。

我目前正在尝试为Windows 8 Metro编写一个简单的DirextX游戏,并且遇到了很多_In_。我只是想知道它是什么。

此外,我看到了很多使用^作为指针*的情况,我觉得这很奇怪。除此之外,有些类有一个ref class MyClass接口,我认为这是为了C#的易读性。

不管怎样,任何帮助都是非常棒的。

它是一个SAL注释,用于代码分析。注释本身被定义为宏,在正常构建中,这些宏可以扩展为零。

^ref class是C++/CX的功能,这是一组语言扩展,旨在使在C++中为Windows 8构建Metro风格的应用程序变得更容易。两者都不是标准C++的一部分。该文档(以前链接过)具有指向教程的链接和描述语言扩展的参考资料。

我认为(从快速谷歌中)_in_是用来指示参数是函数/方法的输入还是输出(_out_)的。

^是一个托管指针(垃圾回收指针,与C++/CLI相关)。

sal.h文件中,o找到了此定义

// Input parameters --------------------------
//   _In_ - Annotations for parameters where data is passed into the function, but not modified.
//          _In_ by itself can be used with non-pointer types (although it is redundant).
// e.g. void SetPoint( _In_ const POINT* pPT );
#define _In_                            _SAL2_Source_(_In_, (), _Pre1_impl_(__notnull_impl_notref) _Pre_valid_impl_ _Deref_pre1_impl_(__readaccess_impl_notref))
#define _In_opt_                        _SAL2_Source_(_In_opt_, (), _Pre1_impl_(__maybenull_impl_notref) _Pre_valid_impl_ _Deref_pre_readonly_)

_Out_表示作为引用传递的参数。CCD_ 11的意思正好相反。CCD_ 12和CCD_。