Important: Please read the Qt Code of Conduct -

Calling ASCII or Unicode version of Windows APIs

  • I am converting a Visual Studio C++ demo that works with USB devices. Now Windows has ANSII and UNICODE version of APIs, this is giving me a lot of trouble.

     C:\code\MyProject\USBDevices.cpp:374: error: C2664: 'USBDevices::EnumerateHostController' : cannot convert parameter 3 from  'WCHAR [1]' to 'PCHAR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

    My question is if I have a structure defined as:

    SP_DEVICE_INTERFACE_DATA         deviceInterfaceData;

    Can I set settings in Qt somewhere to use SP_DEVICE_INTERFACE_DATA_W rather than SP_DEVICE_INTERFACE_DATA_A like Visual Studio does?

  • Hi, actually I think there is only one SP_DEVICE_INTERFACE_DATA structure without _A and _W suffixes (normally A and W are appended for functions, not structures).
    Maybe instead there's a problem with your Unicode settings, usually Qt only defines UNICODE and not _UNICODE which sometimes Windows wants as well.

    Edit: Here's a good explanation about the UNICODE and _UNICODE defines.

Log in to reply