We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I declared a void pointer
void *ptr;
and a typedef struct named testStructure, with a member 'unsigned int a'.
Now I will cast this pointer to a struct pointer:
ptr=(testStructure*)malloc(sizeof(testStructure));
Now I try to access the member of the struct...
ptr->a=5;
...and I get an error "expression must have a pointer-to-struct-or-union type"... Why is 'ptr' still void? It seems, a void pointer cannot be casted to any other pointer type... How I can do this properly? I just need ONE pointer, which can point to different structures, that means, I need to cast a void pointer...
You have 2 conflicting goals. The kernel accessing data, and you not wanting to have an understanding of what it is accessing because it is in a DLL. If the Kernel merely needs to pass the data (pointer) I suppose this works.
Erstwhile making a macro is likely the 'cleanest' route. IE
typedef struct insect { float value; char *name; uint32_t count; } insect; #define INSECT(VPTR) ((insect *)(VPTR)) #define INSECT_VALUE(VPTR) INSECT(VPTR)->value #define INSECT_NAME(VPTR) INSECT(VPTR)->name #define INSECT_COUNT(VPTR) INSECT(VPTR)->count
etc
"Erstwhile (sic?) making a macro is likely the 'cleanest' route."
Is that really the word you were looking for:
www.dictionary.cambridge.org/define.asp