struct init test

This commit is contained in:
Alessandro Mauri 2020-06-09 15:46:44 +02:00
parent 9564915e08
commit 9866fa0533
3 changed files with 22 additions and 1 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ hkd*
tests/parse tests/parse
tests/ioctl tests/ioctl
tests/evtest tests/evtest
tests/struct_init

View File

@ -9,5 +9,7 @@ evtest: evtest.c
inotify: inotify.c inotify: inotify.c
struct_init: struct_init.c
clean: clean:
rm *.o parse ioctl inotify 2> /dev/null rm *.o parse ioctl inotify struct_init 2> /dev/null

18
tests/struct_init.c Normal file
View File

@ -0,0 +1,18 @@
#include <stdio.h>
#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;
}