Sure, the standard C preprocessor is very limited.
I've done such a tool recently: https://github.com/d-ash/perlpp
For example this
<?
my @types = ('char', 'int', 'long');
foreach (@types) {
?>
<?= $_ ?> read_<?= uc($_) ?>(<?= $_ ?>* v);
<? } ?>
becomes this
char read_CHAR(char* v);
int read_INT(int* v);
long read_LONG(long* v);
Syntax is similar to PHP, but it uses Perl instead, and can capture texts into Perl stings.
Edit by cxw — With @d-ash's approval, I am also a maintainer of perlpp. If you have questions, feel free to drop me a line!