You can use PHP as a C preprocessor. The advantages are:
- very similiar syntax, so syntax highlighting works.
<?
and?>
are not used in standard C (with non-standard C, the only thing that gets broken is old GCC extension operator that returns min/max)- it’s rich in libraries.
- it’s turing complete.
- usage of macros is very explicit. (compared to sneaky C preprocessor macros)
For serious use though, making PHP print the #line directives is needed for debugging preprocessed code.
<?php include_once "stdio.h"; ?>
int main()
{
<?php
for($i = 0; $i < 20; $i++)
echo 'printf("%d\n", '.$i.');';
?>
}