Help with data retrieval MACRO
- by Andrei Ciobanu
Hello, given the following structure:
struct nmslist_elem_s {
nmptr data;
struct nmslist_elem_s *next;
};
typedef struct nmslist_elem_s nmslist_elem;
Where:
typedef void* nmptr;
Is it possible to write a MACRO that retrieves the data from the element and cast it to the right type:
MACRO(type, element) that expands to *((type*)element->data).
For example for int, i would need something like this: *((int*)(element->data)) .