为什么unknw.h中需要三个前瞻性声明
Why are the three forward declarations necessary in unknwn.h?
我正在使用JNAngator来解析windows API头文件,这样我就可以从JVM中引用它们。然而,我对C/C++不像其他语言那样熟悉,但我需要理解这些头文件,然后才能正确解析它们。
我特别关注Unkwn.h,它基本上包含
#include "rpc.h"
#include "rpcndr.h"
#ifndef COM_NO_WINDOWS_H
#include "windows.h"
#include "ole2.h"
#endif /*COM_NO_WINDOWS_H*/
//Some forward declarations
typedef interface IUnknown IUnknown;
typedef interface AsyncIUnknown AsyncIUnknown;
typedef interface IClassFactory IClassFactory;
#include "wtypes.h"
//followed by the full declarations for the interfaces IUnkown, AsyncIUnkown and IClassFactory and their methods, but no actual implementations of course.
如果类型(IUnkown、AsynUnkown或IClassFactory)被wtypes.h引用,我认为这些正向定义是必要的,但我在wtypes.小时或wtypes.h引用的其他标头中找不到对这些类型的任何引用。那么,为什么需要前瞻性声明(或者我错过了什么)?
这些不是正向声明。这些是类型定义,它们定义接口数据类型。这当然是微软的扩展。定义所做的是确保IUnknown
(例如)引用该名称的接口。
相关文章:
- 模板-模板参数推导:三个不同的编译器三种不同的行为
- 在 2D 向量中使用第三个 [ ] 有什么意义?
- 如何通过按下第三个窗口中的按钮,将QString从一个窗口获取到另一个窗口
- 如何知道n!是否可以表示为三个连续数字的乘法?
- 我有三个 getline,但是一旦编译,输入就太多了
- 我遇到了黑客排名中的问题"TWO STRINGS"的三个测试用例的分段错误。原因是什么?
- 有没有更好的方法对C++中的三个整数进行排序?
- 如何检查第三个 API 是否在 Linux 中为 c/c++ 程序创建了一个新线程?
- 为什么 getch 在按下函数或箭头键时返回三个值?
- 使用三个数字比较器进行排序
- 我想在C++代码中比较这三个术语
- 我的动态链接队列在同一输出流中调用时不正确地输出三个返回函数
- 我该如何编码,使计算机知道两个名称条目和三个名称条目之间的区别
- 为什么我需要三个嵌套的大括号来调用赋值运算符,将const引用到二维数组
- 如何通过通用引用或std::forward将这三个c++模板函数合并为一个
- 首先处理第二个和第三个堆与第一个和第二个堆之间的逻辑差异
- 异常处理:如果用户输入不是三个特定字符之一
- 为什么将三个变量与 == 一起比较会计算为 false?
- 重载运算符 new 和运算符 delete 带有三个参数
- 为什么unknw.h中需要三个前瞻性声明