Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef struct ball {} Ball;
- typedef struct point {} Point;
- void destroy_ball()
- {
- puts("Ball putt, neue kaufen.");
- }
- void destroy_point()
- {
- puts("Point futsch, was tun...");
- }
- #define type(x) _Generic((x), Point: "Point", Ball: "Ball", default: ":(")
- #define n_args(...) n_args_impl(0, __VA_ARGS__, 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)
- #define n_args_impl(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,N,...) N
- #define clean_up(args...) clean_up_helper(n_args(args), args);
- static inline void clean_up_helper(unsigned int arg_c, ...)
- {
- va_list vl;
- va_start(vl, arg_c);
- for (unsigned int i = 0; i < arg_c; ++i)
- {
- /*
- ??type?? arg = va_arg(vl, ??type??);
- wenn strcmp(type(x), "Ball") == 0
- destroy_ball
- ...
- */
- }
- va_end(vl);
- }
- int main(void)
- {
- Ball b;
- Point p;
- clean_up(b, p);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement