I would like something like the following gperf input file:
%{
#include <keywords.h>
// the contents of which contain
// #define KEYWORD1_MACRO "keyword1"
// #define KEYWORD2_MACRO "keyword2"
%}
%%
KEYWORD1_MACRO
KEYWORD2_MACRO
%%
Unfortunately, gperf will interpret those as the stings "KEYWORD1_MACRO", etc.
The reason for this is that I have a protocol spec provided by another party as a header file, containing such #define
s. So I don't have control over how they are defined, and I'd rather not have to write another preprocessing tool to #include
the header and output the expansion of the macros as quoted strings, only then for use as a gperf input file.
I made the following experiment which uses
gcc -E
to deal with those#include
s.keywords.h:
test.c:
Command:
gcc -E -o test.out.txt test.c
.Then, the content in test.out.txt:
The
#include
s are handled automatically. You can then do some text processing and feed intogperf
.