{}
run-icon
main.c
#include <stdio.h> #define FIELDS(MACRO) \ MACRO(one) \ MACRO(two) \ MACRO(three) #define DEFINE_FIELD(name) int name; struct Struct { FIELDS(DEFINE_FIELD) }; #define PRINT_FIELD(name) printf(#name ": %d\n", s.name); void print(struct Struct s) { FIELDS(PRINT_FIELD) } int main() { struct Struct s = {1, 2, 3}; print(s); return 0; }
Output