[plt-scheme] Re: Generating C code

From: Dave Herman (dherman at ccs.neu.edu)
Date: Fri May 15 13:57:05 EDT 2009

Neil wrote:
>> In answer to your question "print-source" appears to be just a thunk that
>> writes the desired C code to current-output.  For example:

That's correct. It's just a thunk that you have to provide that prints 
raw C source code to the current-output-port.

There are no facilities in the library for pretty-printing C. I may 
implement that some day, but I have a dissertation to write...

Paulo wrote:
> So, can you convert the abstract syntax structures into source?

*You* can, but I'm afraid there's nothing there to help you. :)

In general, (ugly)-printing is not too hard -- certainly easier than 
parsing -- but pretty-printing is somewhat difficult. You can use my 
pprint.plt PLaneT package to help you, though I'm still not satisfied 
with the reliability of that package (I think it's still suffering some 
subtle algorithmic complexity problems).


But printing C is trickier, because its syntax, particularly the syntax 
of types, is freakishly weird.

Neil wrote:
>> One thing to note: it looks like currently you cannot supply custom
>> command-line arguments to the "gcc" program using this "gcc" procedure.

That's true. I'm only implementing functionality on a by-need basis, but 
I'm always open to specific requests. It's better to email me directly 
because I don't always notice threads on plt-scheme.


Posted on the users mailing list.