#include <stdio.h>
struct _doThing {
int x; int y;
};
void _doThing(struct _doThing options)
{
printf("x=%d y=%d\n", options.x, options.y);
}
#define doThing(...) _doThing((struct _doThing){ __VA_ARGS__ })
int main(void)
{
/* these are all equivalent */
doThing(.x = 64, .y = 1);
doThing(.y = 1, .x = 64);
doThing(64, 1);
return 0;
}
made with @nex3's syntax highlighter
i tested this and it works with the most recent GCC and Clang installed on my system. feels cursed as hell, but i kinda like it actually. lol
thanks to @wavebeem for inspiring me to do this