Error: Request for member (perhaps you wanted to use '->'?) When using '->' already
Is there an easy explanation for what this error means?
error: Request for member attributes in '* printerInfo' which is of pointer type 'PPRINTER_INFO_2 {aka _PRINTER_INFO_2A *}' (you might mean to use '->'?)
PPRINTER_INFO_2* printerInfo = NULL;
void ChangedPrinter()
{
...
DWORD attributesPrinterInfo;
printerInfo = (PPRINTER_INFO_2*) malloc(bufferSize);
attributesPrinterInfo = printerInfo->Attributes; // error
free(printerInfo);
}
What am I doing wrong?
source to share
The PRINTER_INFO_2 structure is defined as:
typedef struct _PRINTER_INFO_2 {
// ...
} PRINTER_INFO_2, *PPRINTER_INFO_2;
therefore PPRINTER_INFO_2
is a pointer to PRINTER_INFO_2
. When you do
printerInfo = (PPRINTER_INFO_2*) malloc(bufferSize);
printerInfo
actually becomes a pointer to a pointer to PRINTER_INFO_2
. I'm not sure if this was the intent or just a mistake, but if it intended to be PPRINTER_INFO_2*
, then the correct usage is:
(*printerInfo)->Attributes
source to share