Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Learning that you can use unions in C for grouping things into namespaces. Parent comment
struct bar_arguments { int a, b; }; int bar(struct bar_arguments args) { return 2*args.a + args.b;} #define bar(...) bar((struct bar_arguments) {__VA_ARGS__}) // usage (will print 32 three times) printf("%d\n", bar(10, 12)); printf("%d\n", bar(.a = 10, .b = 12)); printf("%d\n", bar(.b = 12, .a = 10));
printf("%d\n", bar(10)); printf("%d\n", bar(.a = 10)); printf("%d\n", bar(.b = 12));
You can change those "default values", but then calling the function with regular positional parameters is impaired :-/
There are no comments on this comment yet.
You can change those "default values", but then calling the function with regular positional parameters is impaired :-/