How to check if GUID is equal

What is the most concise but readable way to check if the GUID is zero? I came up with the following code:

GUID myGuid /* = ... */ ; GUID zeroGuid; memset(&zeroGuid, 0, sizeof(zeroGuid)); if (!IsEqualGUID(myGuid, zeroGuid)) { // ... do something if GUID is not zero ... } 

But I think the code is too clumsy. Of course, I could define my own IsZeroGUID () function, but I assume that C ++ already has a built-in function.

Is there a better way?

+6
c ++ guid visual-studio-2008
source share
2 answers

Compare with GUID_NULL :

 if( myGuid != GUID_NULL ) { //do stuff } 
+14
source share

myGUID == zeroGUID should do the trick.

+2
source share

All Articles