Reputation: 346
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*}' (maybe you meant 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???
Upvotes: 3
Views: 20561
Reputation: 165
for Cpp, See this https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91138
Suggesting -> isn't helpful when it already uses it. The right fix-it is to suggest (*pp)->member
Upvotes: 0
Reputation: 42133
PRINTER_INFO_2 structure is defined as:
typedef struct _PRINTER_INFO_2 {
// ...
} PRINTER_INFO_2, *PPRINTER_INFO_2;
so PPRINTER_INFO_2
is pointer to PRINTER_INFO_2
. When you do
printerInfo = (PPRINTER_INFO_2*) malloc(bufferSize);
printerInfo
actually becomes a pointer to pointer to PRINTER_INFO_2
. I'm not sure whether this was an intention or just a mistake, but if it's intended to be PPRINTER_INFO_2*
then proper usage is:
(*printerInfo)->Attributes
Upvotes: 9