4 ms·
How about #include <stdio.h> typedef struct mystruct { int x; char *p; } mystruct; mystruct func(int n) { return (mystruct) { n, NULL };
by ratboy666 11y ago
How about
#include <stdio.h>
typedef struct mystruct {
int x;
char *p;
} mystruct;
mystruct func(int n) {
return (mystruct) { n, NULL };
}
int main(void) {
mystruct v = func(1);
printf("%d\n", v.x);
printf("%d\n", func(2).x);
return 0;
}
Works fine with gcc 5.3.1. Multiple destructuring is (maybe) problematic, but if you really want this.
- scott_s 11y agoThat has both downsides I mentioned.