I'm trying to debug some C# P/Invoke problem with 32/64 bit using the SetupDiGetDeviceInterfaceDetail function. This involves analysing the SP_DEVICE_INTERFACE_DETAIL_DATA structure. For this, I tried to write a simple C++ program to see the data that's not documented. My C skills aren't sufficient to read the structure sizes from the definitions.
Here's the code for a new C++ Windows console application created with Visual Studio 2017:
#include "pch.h"
#include <iostream>
#include <Setupapi.h>
int main()
{
std::cout << "Size: " << sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA) << "\n";
}
As soon as I add the third include, I get 1600+ compiler errors about syntax errors within Microsoft files – missing semicolons, type specifiers and other stuff, spreading over several files like setupapi.h, prsht.h, dpa_dsa.h or commctrl.h. That's well outside my capabilities. Looks like Microsoft has delivered a huge mess. Wondering how Visual Studio was compiled if C++ programming is always like this.
What's wrong here? Why can't I just include that header file as suggested in the documentation?
Is there another way to find out what that sizeof expression would resolve to?
#include <windows.h>before#include <Setupapi.h><windows.h>header file. Additional header files for specific functionality don't redefine the common types they instead need <windows.h> included 1st to provide them.typedef GUID *LPGUID;TheGUIDidentifier has wavy red underline, move mouse there and you’ll see a tooltip saying “identifier GUID is undefined”.