you can;t even IMAGINE what it is

posts from @daddragon tagged #im the c++ defender man

also:

erysdren
@erysdren
#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;
}

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


Β