Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 928061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:57:00+00:00 2026-05-15T19:57:00+00:00

Windows SDK features IsEqualGUID() function and operator==() for two GUIDs that return BOOL (equivalent

  • 0

Windows SDK features IsEqualGUID() function and operator==() for two GUIDs that return BOOL (equivalent to int):

// Guiddef.h
#ifdef __cplusplus
__inline int IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
{
    return !memcmp(&rguid1, &rguid2, sizeof(GUID));
}
#else   // ! __cplusplus
    #define IsEqualGUID(rguid1, rguid2) (!memcmp(rguid1, rguid2, sizeof(GUID)))
#endif
//also in Guiidef.h
#ifdef __cplusplus
__inline int operator==(REFGUID guidOne, REFGUID guidOther)
{
    return IsEqualGUID(guidOne,guidOther);
}
#endif

What’s the point in that int? I understand that C doesn’t have bool datatype, but there’s an #ifdef __cplusplus around, so this code will only be compiled as C++, so bool will be supported anyway. Having a negation near memcmp() effectively transforms all possible values returned from memcmp() into zero and nonzero.

Also there’re no user-defined operators in C – only C++ supports them. So the operator== would not compile in C code anyway.

Are there any reasons for choosing int instead of bool here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T19:57:01+00:00Added an answer on May 15, 2026 at 7:57 pm

    Because the Windows API exposes IsEqualGUID() as a function returning a BOOL. They need to keep a stable interface. BOOL and bool are different sizes, and the Windows API is designed to be compatible with a variety of languages and compilers. Remember that there are other languages other than C++ that interact with the Windows API.

    On C and C++, IsEqualGUID() is implemented in terms of memcmp(), but IsEqualGUID() is also implemented in ole32.dll. You can obtain the function from ole32.dll:

    REFGUID guid1 = IID_IUnknown;
    REFGUID guid2 = IID_AsyncIUnknown;
    typedef BOOL (WINAPI *IsEqualGUIDFuncType)(REFGUID, REFGUID);
    HMODULE h = ::LoadLibrary("ole32.dll");
    IsEqualGUIDFuncType f = reinterpret_cast<IsEqualGUIDFuncType>
        (::GetProcAddress(h, "IsEqualGUID"));
    if(f != NULL)
    {
        if(f(guid1, guid2) != 0)
            ::printf("true\n");
        else
            ::printf("false\n");
    }
    ::FreeLibrary(h);
    

    So even though it’s implemented as an inline function in C++, other languages may use the DLL implementation of IsEqualGUID(). The C++ version returns a BOOL so it is consistent with the API.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Windows SDK features SUCCEEDED macro: #define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0) -----------------------^-------------^----- clearly as with
Windows 8 build 8102, Kinect SDK V1.0 And so it begins that I had
In one of the samples that come w/ Windows SDK (the CreateProcessVerb sample), the
The Windows SDK ships with a tool called signtool.exe that lets you sign a
I am looking into DirectShow samples from Windows SDK. Many of the classes feature
When installing Windows SDK v6.1, following the chromium instructions ( http://dev.chromium.org/developers/how-tos/build-instructions-windows ) I run
in the windows SDK there is this file residing in the Lib-directory. Is it
Does installing the Windows SDK alter an existing installation of Visual Studio 2010? After
I have Visual Studio 2008 and the Windows SDK for Windows Server 2008 and
According the decoder sample in Windows SDK, I realize myself decoder MFT, but there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.