Skip to content

Instantly share code, notes, and snippets.

@hiredman
Created October 31, 2009 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hiredman/223246 to your computer and use it in GitHub Desktop.
Save hiredman/223246 to your computer and use it in GitHub Desktop.
user=>
(cc
#^{:tag :c-program :compiler "gcc" :options "-I/usr/local/include/ -L/usr/local/lib -lgc"
:file-name "test.c" :binary-file "test"}
(#^:include<> ["stdio.h"]
#^:include<> ["gc.h"]
"typedef union se {struct cons * cp; int i;} sexp;\n"
"struct cons {union se head; union se tail;};\n"
(#^:int main []
{#^:int x 1
#^:int m 2}
{#^:int w #^:call (printf "Hello Wolrd %d\n" x)}
#^:call (printf "%d\n" w)
#^:call (hello "Hello World\n")
#^:call (return 0))
(#^:void hello [#^:char* s]
#^:call (printf "%s" s))))
gcc -I/usr/local/include/ -L/usr/local/lib -lgc test.c -o test
#<user$eval__2004$fn__2006 user$eval__2004$fn__2006@15291cd>
user=> (-> *1 (apply nil) .getInputStream is->string print)
Hello Wolrd 1
14
Hello World
nil
user=>
;cat test.c
#include<stdio.h>
#include<gc.h>
typedef union se {struct cons * cp; int i;} sexp;
struct cons {union se head; union se tail;};
int main ()
{
int x = 1;
int m = 2;
int w = printf("Hello Wolrd %d\n",x);
;
printf("%d\n",w);
hello("Hello World\n");
return(0);
}
void hello ( char* s)
{
printf("%s",s);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment