Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- body="$1"
- out=$(mktemp /tmp/ccrun-XXXXXX)
- src=${out}.c
- cat > ${src} <<EOF
- #include <limits.h>
- #include <string.h>
- #include <math.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdint.h>
- #define UNUSED __attribute__((unused))
- int main(int UNUSED argc,char UNUSED *argv[])
- {
- EOF
- echo "$body" >> ${src}
- echo -e "return 0;n}" >> ${src}
- cc -std=c99 -Wall -Wextra ${CCRUN_FLAGS} -o ${out} ${src} -lm
- shift
- echo ${out} "$@"
- ${out} "$@"
- #rm ${out} ${src}
- $ ccrun 'int f(int a){return a+1;} int g(int a){return a+2;} int (*farr[2])(int) = {f,g}; for (int i=0; i<2; i++) printf("%d %dn",i,farr[i](i));'
- /tmp/ccrun-6nT4Wo
- 0 1
- 1 3
Add Comment
Please, Sign In to add comment