Spent a while hacking this little pipe to grab the configuration constants for the Marline firmware on my Rostock 3D printer:
echo "$(grep -e '^#define' Configuration.h)$(echo -e "\nDELTA_DIAGONAL_ROD")" | gcc -E - | tail -n 1
The first part,
echo "$(grep -e '^#define' Configuration.h)$(echo -e "\nDELTA_DIAGONAL_ROD")"
will spit out all the #define lines in Configuration.h, followed by a newline (echo -e) and the symbol I am after. Having newlines within bash variables still feels like magic :)
After that, I rely on standard Unix notation to make gcc use standard input (“-”). The gcc documentation doesn’t seem to mention this possibility.
Note to self: find a way of using markdown on Blogger – straight HTML and the “Composer” are equally horrible for geeky stuff.