Help with data retrieval MACRO

Posted by Andrei Ciobanu on Stack Overflow See other posts from Stack Overflow or by Andrei Ciobanu
Published on 2010-06-07T15:52:48Z Indexed on 2010/06/07 16:02 UTC
Read the original article Hit count: 259

Filed under:
|
|
|

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)) .

© Stack Overflow or respective owner

Related posts about c

    Related posts about pointers