[plt-scheme] Re: Generating C code
On Fri, May 15, 2009 at 1:20 PM, Neil Van Dyke <neil at neilvandyke.org> wrote:
> Paulo J. Matos wrote at 05/15/2009 07:53 AM:
>>
>> (gcc print-source)
>>
>> What is print-source? It says, it invokes print-source, but without
>> being able to search the docs online or having a link, can't really
>> understand exactly what gcc receives.
>>
>
> If you install the PLaneT package, you can search the docs in your Web
> browser from the local copy of the package.
>
> In answer to your question "print-source" appears to be just a thunk that
> writes the desired C code to current-output. For example:
>
So, can you convert the abstract syntax structures into source?
> #lang scheme
> (require (planet dherman/c:3:1/eval))
> (let-values (((stdin stdout)
> (gcc (lambda ()
> (display "#include <stdio.h>\n")
> (display "int main(int argc, char **argv) {\n")
> (display " (void)printf(\"(hello world)\");\n")
> (display "}\n")))))
> (read stdin))
> ;; ==> (hello world)
>
> One thing to note: it looks like currently you cannot supply custom
> command-line arguments to the "gcc" program using this "gcc" procedure.
>
> --
> http://www.neilvandyke.org/
>
--
Paulo Jorge Matos - pocmatos at gmail.com
Webpage: http://www.personal.soton.ac.uk/pocm