编译器错误 C2778

__declspec(uuid()) 中的 GUID 格式不正确

uuid 扩展属性提供了不正确的 GUID。

GUID 必须是具有以下格式的十六进制数字字符串:

// C2778a.cpp
// compile with: /c
struct __declspec(uuid("00000000-0000-0000-0000-000000000000")) A {};
struct __declspec(uuid("{00000000-0000-0000-0000-000000000000}")) B{};

uuid 扩展属性接受由 CLSIDFromString 识别的字符串,可带或不带大括号分隔符。

以下示例生成 C2778:

// C2778b.cpp
struct __declspec(uuid(" 00000000-0000-0000-0000-000000000000 ")) C { };   // C2778
struct __declspec(uuid("00000000000000000000000000000000")) D { };   // C2778