1
2
3
4
5
6
7
8
9
10
11
[chshrcat@alice build]$ cat test.c
struct test_struct {
        char a;
        char b;
        char c;
};

const s_test_struct = sizeof(struct test_struct);

[chshrcat@alice build]$ arm-elf-eabi-gcc -S -o - test.c | perl -ne 'if (/^(\w+):$/) {$var=$1} else { /^\W\.word\W(.*)$/ && print "#define $var $1\n" ; $var=0 }'
#define s_test_struct 3