共用方式為


編譯器錯誤 C2788

'identifier' :與這個對象相關聯的多個 GUID

__uuidof運算符會採用具有附加 GUID 的使用者定義型別,或是這類使用者定義型別的物件。 當自變數是具有多個 GUID 的物件時,就會發生此錯誤。

下列範例會產生 C2788:

// C2788.cpp
#include <windows.h>
struct __declspec(uuid("00000001-0000-0000-0000-000000000000")) A {};
struct __declspec(uuid("{00000002-0000-0000-0000-000000000000}")) B {};
template <class T, class U> class MyClass {};

typedef MyClass<A,B> MyBadClass;
typedef MyClass<A,A> MyGoodClass;

int main() {
   __uuidof(MyBadClass);    // C2788
   // try the following line instead
   __uuidof(MyGoodClass);
}