DEFINE_GUID宏是怎么工作的?

标签:
define_guid驱动开发it |
分类: 驱动开发 |
|
-
#ifndef
DEFINE_GUID -
#error
initguid: must include objbase.h first. -
#endif
-
#undef
DEFINE_GUID -
#ifdef
_MAC -
#define
__based(a) -
#endif
-
#ifdef
_WIN32 -
#define
__based(a) -
#endif
-
#ifdef
__TURBOC__ -
#define
__based(a) -
#endif
-
#ifndef
_MAC -
#define
DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) / -
EXTERN_C const GUID "_CODE"))__based(__segname( name / -
= { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } -
#else
-
#define
DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) / -
EXTERN_C const GUID name / -
= { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } -
#endif
上面是initguid.h的源代码
The GUID value must be defined exactly once in your project, and the other source files must declare extern references to it。
Globally Unique Identifier(全球唯一标识符) 也称作 UUID(Universally Unique IDentifier)
GUID/UUID是通过特定算法产生的一个二进制长度为128位的数字,
在空间上和时间上具有唯一性,保证同一时间不同地方产生的数字不同,
在公元3400年以前产生的UUID/GUID与任何其他产生过的UUIDs/GUIDs都不相同。
在需要GUID的时候,可以完全由算法自动生成,不需要一个权威机构来管理。
GUID的长度固定,并且相对而言较短小,非常适合于排序、标识和存储。