Last active
September 16, 2021 14:38
-
-
Save Hermann-SW/7bc1a49b90adabed45f5775b15139c5f to your computer and use it in GitHub Desktop.
C script runs C code without temp space (tcc -run) and script stdin available to C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "foo" | |
tcc -run <(sed -n "/^\/\*\*$/,\$p" $0) 42 | |
exit | |
/** | |
*/ | |
#include <stdio.h> | |
int main(int argc, char *argv[]) | |
{ | |
printf("bar %s\n", argv[1]); | |
for(int ch=getchar(); EOF!=ch; ch=getchar()) | |
putchar(ch); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Demos passing "42" as argv[1], and keeping C code stdin the same as C script stdin: