From 9866fa0533eff9a7dfcfbb7ff896936c47d19abf Mon Sep 17 00:00:00 2001 From: Alessandro Mauri Date: Tue, 9 Jun 2020 15:46:44 +0200 Subject: [PATCH] struct init test --- .gitignore | 1 + tests/makefile | 4 +++- tests/struct_init.c | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 tests/struct_init.c diff --git a/.gitignore b/.gitignore index 0e268a8..2bb1cd8 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ hkd* tests/parse tests/ioctl tests/evtest +tests/struct_init diff --git a/tests/makefile b/tests/makefile index 70a608f..59fb382 100644 --- a/tests/makefile +++ b/tests/makefile @@ -9,5 +9,7 @@ evtest: evtest.c inotify: inotify.c +struct_init: struct_init.c + clean: - rm *.o parse ioctl inotify 2> /dev/null + rm *.o parse ioctl inotify struct_init 2> /dev/null diff --git a/tests/struct_init.c b/tests/struct_init.c new file mode 100644 index 0000000..36b4f02 --- /dev/null +++ b/tests/struct_init.c @@ -0,0 +1,18 @@ +#include + +#define HELL 10 +#define IDE 220 +#define MAKE_ENTRY(value) {"value", value} +const struct { + const char * const name; + const unsigned short value; +} init[] = { +{"lol", 1}, +{"hello", HELL}, +MAKE_ENTRY(IDE) +}; + +int main (void) { + printf("%s\t%d\n", init[2].name, init[2].value); + return 0; +}