> One time structs are usually redeclared on multiple places. It is really hard maintain such code.
Well, if you don't need forward declarations, you can define structs inline in function signature:
#include <stdio.h>
struct ret { int a; int b} hello(int c) {
return (struct ret){ c, c + 1 };
}
int main(int argc, char **argv) {
struct ret result = hello(2);
printf("%d %d", result.a, result.b);
}
I'm not sure how portable it is though, works in gcc and in whatever ideone is using:
https://ideone.com/bgZUPS