idl_quote

允许你使用当前版本的 Visual C++ 不支持的 IDL 构造,并将其传递到生成的 .idl 文件。

语法

[ idl_quote(text) ]

参数

text
你希望 Microsoft C++ 编译器传递到生成的 .idl 文件而不会返回编译器错误的特性名称。

备注

如果 idl_quote C++ 特性用作独立特性(在右括号后带有分号),则 text 将按原样置于合并的 .idl 文件中。 如果在符号上使用 idl_quote,则 text 将置于该符号的特性块中。

示例

以下代码显示如何指定不受支持的特性(使用受支持的 in),以及如何定义和使用未定义的 .idl 构造:

// cpp_attr_ref_idl_quote.cpp
// compile with: /LD
#include <unknwn.h>
[module(name="MyLibrary")];

[export]
struct MYFLOT {
   int i;
};

[export]
struct MYDUB {
   int i;
};

[idl_quote("typedef union _S1_TYPE switch (long l1) U1_TYPE { case 1024: \
struct MYFLOT f1; case 2048: struct MYDUB d2; } S1_TYPE;") ];

typedef struct _S1_TYPE {
   long l1;

union {
   MYFLOT f1; MYDUB d2; } U1_TYPE;
} S1_TYPE;

[uuid("2F5F63F1-16DA-11d2-9E7B-00C04FB926DA"), object]
__interface IStatic{
   HRESULT Func1([idl_quote("in")] int i);
   HRESULT func( S1_TYPE* myStruct );
};

此代码导致 MYFLOT 和 MYDUB 以及 text 条目被置于生成的 .idl 文件中。 name 参数强制将 text 置于生成的 .idl 文件中引用 name 的任何内容之前。 dependencies 参数强制将依赖项列表定义置于生成的 .idl 文件中的 text 的前面。

要求

特性上下文 值
适用于 任何位置
可重复 否
必需的特性 无
无效的特性 无

有关详细信息,请参见 特性上下文。

另请参阅

IDL 特性
独立特性