KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I was wondering if it is possible to iterate over arguments passed to a variadic macro in C99 or using any GCC extensions ? For e.g. is it possible to write a generic macro that takes a structure and its fields passed as arguments and prints offset of each field within the structure ? Something like this: struct a { int a; int b; int c; }; /* PRN_STRUCT_OFFSETS will print offset of each of the fields within structure passed as the first argument. */ int main(int argc, char *argv[]) { PRN_STRUCT_OFFSETS(struct a, a, b, c); return 0; }
Tags (comma-separated)
Save Edits
Cancel