Skip to content

Instantly share code, notes, and snippets.

@detomon
Created June 29, 2018 09:18
Show Gist options
  • Save detomon/6111c0fc1249e8905269225ddf50b7f9 to your computer and use it in GitHub Desktop.
Save detomon/6111c0fc1249e8905269225ddf50b7f9 to your computer and use it in GitHub Desktop.
#define VALUE_REF(S) (&((struct { typeof(S) s; }) { (S) }).s)
typedef struct {
int a;
int b;
} value;
int* i = VALUE_REF(12);
float* f = VALUE_REF(45.6f);
value* v = VALUE_REF(((value) { .a = 12, .b = 13 }));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment