lxrでlivepatch-sample.cを見ててふと気づいた。確かにこういうやり方もあるな。
#include <stdio.h>
struct test_struct {
int n;
char *str;
};
struct test_struct foo[] = {
{
.n = 10,
.str = "hello, world",
},
{
.n = 5,
.str = "foobar",
}, {}
};
int main(int argc, char **argv)
{
for (struct test_struct *p = foo; p->str; p++)
printf("%d: %s\n", p->n, p->str);
return 0;
}
gcc -std=c11 a.c
で。