Skip to content

Instantly share code, notes, and snippets.

@fxff
Created November 14, 2019 11:35
Show Gist options
  • Save fxff/3ce7c312cc7aaa9ee5888d100148752f to your computer and use it in GitHub Desktop.
Save fxff/3ce7c312cc7aaa9ee5888d100148752f to your computer and use it in GitHub Desktop.
#include <stdio.h>
typedef struct {
int foo;
int bar;
} A;
typedef struct {
char foo;
char bar;
} B;
typedef union
{
int type;
A a;
B b;
} Returnable;
Returnable func (void)
{
Returnable r;
r.a.foo = 200;
r.a.bar = 300;
r.type = 100;
return r;
}
int main (void)
{
Returnable r = func();
printf("%i\n", r.a.foo);
return -1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment