开发者

How do I forward declare HANDLE? (Win32)

How do I forward decl开发者_开发百科are HANDLE? I don't want to include all of windows.h in this particular header.


The header that actually typedefs HANDLE is winnt.h. Unfortunately this is 15K lines - here, so fixing your issue by including the slimline windef.h is a bit misleading.

Here is the relevant part on my system (obviously the details could change from revision to revision, but won't change at the implementation level since this would break existing binaries):

//
// Handle to an Object
//

#ifdef STRICT
typedef void *HANDLE;
#if 0 && (_MSC_VER > 1000)
#define DECLARE_HANDLE(name) struct name##__; typedef struct name##__ *name
#else
#define DECLARE_HANDLE(name) struct name##__{int unused;}; typedef struct name##__ *name
#endif
#else
typedef PVOID HANDLE;
#define DECLARE_HANDLE(name) typedef HANDLE name
#endif
typedef HANDLE *PHANDLE;

PS gotta love that #if 0 in this shipping Microsoft header file.


Well, looks like I answered this one myself. I just #includeed <windef.h> instead of <windows.h> for now. I would still like to be able to forward declare just HANDLE if anyone has a way of doing so.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜