Skip to content

Instantly share code, notes, and snippets.

@mansr
Created May 14, 2012 15:23
Show Gist options
  • Save mansr/2694556 to your computer and use it in GitHub Desktop.
Save mansr/2694556 to your computer and use it in GitHub Desktop.
#include <stdio.h>
static void foo(void)
{
puts("hello world");
}
struct {
const int *data;
void (*func)(void);
} bar = {
(const int []){ 0 },
foo,
};
int main(void)
{
bar.func();
return 0;
}
#include <stdio.h>
struct {
const int *data;
int a;
} bar = {
(const int []){ 0 },
42,
};
int main(void)
{
printf("%d\n", bar.a);
return 0;
}
#include <stdio.h>
struct {
const int *data;
int a;
} bar = {
(const int []){ 0 },
42,
};
int main(void)
{
printf("%d\n", bar.data[0]);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment