开发者

How to check whether GUID is zero

开发者 https://www.devze.com 2023-02-07 14:20 出处:网络
What is the most concise yet readable way to check whether a GUID is zero? I have come up with the following code:

What is the most concise yet readable way to check whether a GUID is zero? I have come 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 above code is too clumsy. Of course, I could define my own IsZeroGUID() function, but I guess that there already is built-in function in C++.

Is there a better 开发者_如何转开发way?


Compare with GUID_NULL:

if( myGuid != GUID_NULL ) {
    //do stuff
}


myGUID == zeroGUID should do the trick.

0

精彩评论

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