- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
// I'm interested in using something other than the C preprocessor to preprocess my C and Objective-C source code. Are there good alternatives?
//
// ---
//
// 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.');';
?>
}
phpBidlokoder2 25.01.2020 10:11 # 0
gost 25.01.2020 10:16 # 0
HoBorogHuu_nemyx 25.01.2020 10:57 # 0
bootcamp_dropout 25.01.2020 20:19 # +2
HoBorogHuu_nemyx 27.01.2020 06:52 # 0
1024-- 27.01.2020 18:10 # +1
bormand 27.01.2020 18:12 # +1
HoBorogHuu_nemyx 27.01.2020 21:15 # 0
AHaHkacmHbIu_nemyx 25.08.2021 17:53 # 0