PDA

View Full Version : Allocating memory for a windows structure



HyperEngineer
2nd June 2013, 14:24
I am trying to allocate memory for a SP_DEVICE_INTERFACE_DATA structure.
In a Windows based program using VS2008 I successfully used this:


#include <windows.h>
#include <winbase.h>

...

SP_DEVICE_INTERFACE_DATA deviceinterface;
SecureZeroMemory(&deviceinterface, sizeof(SP_DEVICE_INTERFACE_DATA));

...


In QT 4 using netbeans 7.2.1 I am trying to use:


#include <windows.h>
#include <winbase.h>

...

SP_DEVICE_INTERFACE_DATA devInterfaceInfo;
devInterfaceInfo =
(SP_DEVICE_INTERFACE_DATA)malloc(sizeof(SP_DEVICE_ INTERFACE_DATA));

...


In QT 4 I get the following error:


QEnumerator.cpp:57: error: no matching function for call to '_SP_DEVICE_INTERFACE_DATA::_SP_DEVICE_INTERFACE_D ATA(void*)'
c:\qtsdk\mingw\bin\../lib/gcc/mingw32/4.4.0/../../../../include/setupapi.h:722: note: candidates are: _SP_DEVICE_INTERFACE_DATA::_SP_DEVICE_INTERFACE_DA TA()
c:\qtsdk\mingw\bin\../lib/gcc/mingw32/4.4.0/../../../../include/setupapi.h:722: note: _SP_DEVICE_INTERFACE_DATA::_SP_DEVICE_INTERFACE_DA TA(const _SP_DEVICE_INTERFACE_DATA&)


I have successfully used the malloc() function in QT 4 for other structures and devtypes.
Any help would be appreciated.

Thanks
DCM

Lesiok
2nd June 2013, 15:25
This is not a Qt problem but the gcc problem. Qt is only C++ library.

HyperEngineer
2nd June 2013, 15:34
Thanks, Lesiok. I will look elsewhere.

DCM