What library should I link to get proper definition of WinRT's “EXTERN_C const IID IID___x_ABI_*”

坚强是说给别人听的谎言 提交于 2019-12-13 20:27:50

问题


Here is some raw C code using windows.gaming.input.h API:

    HSTRING gamepadClassName;
    if (FAILED(WindowsCreateString(RuntimeClass_Windows_Gaming_Input_Gamepad,
            HbArrayLength(RuntimeClass_Windows_Gaming_Input_Gamepad) - 1, &gamepadClassName))) {
        Error("Failed to create a WinRT string reference for Windows.Gaming.Input.Gamepad class name.");
    }
    static IID const gamepadStaticsInterfaceID = { 0x8BBCE529, 0xD49C, 0x39E9, { 0x95, 0x60, 0xE4, 0x7D, 0xDE, 0x96, 0xB7, 0xC8 } };
    if (FAILED(RoGetActivationFactory(gamepadClassName, &gamepadStaticsInterfaceID, &HbInputi_Windows_Gamepad_Statics))) {
        Error("Failed to get the IGamepadStatics activation factory for Windows.Gaming.Input.Gamepad.");
    }
    WindowsDeleteString(gamepadClassName);

Is there any way to get rid of this gamepadStaticsInterfaceID GUID definition in code? I tried to use IID___x_ABI_CWindows_CGaming_CInput_CIGamepadStatics declared in windows.gaming.input.h header but then then I have error LNK2001: unresolved external symbol IID___x_ABI_CWindows_CGaming_CInput_CIGamepadStatics. What lib should I link to properly define IID___x_ABI_CWindows_CGaming_CInput_CIGamepadStatics?


回答1:


This appears to be not included in the SDK.

Typically, this would come from a lib like uuid.lib. However, I see no evidence that the IID's for Windows.Gaming (or other winrt types that I've spot-checked) are supplied this way in any library in the Windows SDK. C usage is supported for winrt types, but very lightly used.

I'll open a bug to track this when I get back into the office tomorrow. For now, your only option is to define the GUID in your code as you've done here.

Ben Kuhn (MSFT)



来源:https://stackoverflow.com/questions/55573362/what-library-should-i-link-to-get-proper-definition-of-winrts-extern-c-const-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!