Cannot compile when I include the Windows.Devices.Enumeration.h file

Viewed 95

I have a Visual Studio 2017 C++17 MFC project on Windows 10 using Windows SDK 10.0.18362.0. I need to add code to enumerate and connect to a Bluetooth LE device.

To start off, the first thing I need to do is to

#include <winrt/Windows.Devices.Enumeration.h> 

The winrt/ header files are in C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\cppwinrt\winrt

If I wanted to go with the ABI:: headers then I would

#include <Windows.Devices.Enumeration.h> 

Those header files are in C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\winrt

Here is the problem. If I comment out this include, I have no compile errors but if I add either one I get compile errors.

Regardless of which include I use I get a mountain of errors such as Error C2059 syntax error: 'constant' which points to DirectXMathVector.inl (a MS C++ Math Library) the line pointed to is

XMVECTOR A = XMVectorSelect(g_XMSelect1110.v, V, g_XMSelect1110.v);

Or, if I use the 2nd ABI include mentioned above I get a ton of compile errors such as Error C2027 use of undefined type 'ABI::Windows::Foundation::Internal::GetAbiType' which is in the windows.foundation.collections.h file and the line pointed to is

typedef typename Windows::Foundation::Internal::GetAbiType<T>::type _abi_type;

So what's the deal? How can VS2017 with C++2017 and a recent SDK not be able to compile MS's own files? Does this compile with VS2019? I don't have that to test.

TIA,

Ed

1 Answers

As a follow up. The thing that I found that worked was a Project Properties setting. Properties > C/C++ > General node in the left pane. Set the Consume Windows Runtime Extension property to Yes

Related