</sect1>
-->
- <sect1 id="hs2c">
+ <sect1 id="hsc2hs">
<title>Writing Haskell interfaces to C code:
- <command>hs2c</command></title>
- <indexterm><primary><command>hs2c</command></primary>
+ <command>hsc2hs</command></title>
+ <indexterm><primary><command>hsc2hs</command></primary>
</indexterm>
- <para>The <command>hs2c</command> command can be used to automate
+ <para>The <command>hsc2hs</command> command can be used to automate
some parts of the process of writing Haskell bindings to C code.
It reads an almost-Haskell source with embedded special
constructs, and outputs a real Haskell file with these constructs
two files are created when the <literal>#def</literal> construct
is used.</para>
- <para>Actually <command>hs2c</command> does not output the Haskell
+ <para>Actually <command>hsc2hs</command> does not output the Haskell
file directly. It creates a C program that includes the headers,
gets automatically compiled and run. That program outputs the
Haskell code.</para>
<term><literal>#include "file.h"</literal></term>
<listitem>
<para>The specified file gets included into the C program,
- the compiled Haskell file, and the C
- header. <literal><HsFFI.h></literal> is included
+ the compiled Haskell file, and the C header.
+ <literal><HsFFI.h></literal> is included
automatically.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>#define name</literal></term>
<term><literal>#define name value</literal></term>
+ <term><literal>#undef name</literal></term>
<listitem>
<para>Similar to <literal>#include</literal>. Note that
<literal>#includes</literal> and
</varlistentry>
<varlistentry>
+ <term><literal>#let name parameters = "definition"</literal></term>
+ <listitem>
+ <para>Defines a macro to be applied to the Haskell
+ source. Parameter names are comma-separated, not
+ inside parens. Such macro is invoked as other
+ <literal>#</literal>-constructs, starting with
+ <literal>#name</literal>. The definition will be
+ put in the C program inside parens as arguments of
+ <literal>printf</literal>. To refer to a parameter,
+ close the quote, put a parameter name and open the
+ quote again, to let C string literals concatenate.
+ Or use <literal>printf</literal>'s format directives.
+ Values of arguments must be given as strings, unless the
+ macro stringifies them itself using the C preprocessor's
+ <literal>#parameter</literal> syntax.</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><literal>#option opt</literal></term>
<listitem>
<para>The specified Haskell compiler command-line option
<term><literal>#elif condition</literal></term>
<term><literal>#else</literal></term>
<term><literal>#endif</literal></term>
+ <term><literal>#error message</literal></term>
<listitem>
<para>Conditional compilation directives are passed
unmodified to the C program, C file, and C header. Putting
<para><literal>#const</literal>, <literal>#type</literal>,
<literal>#peek</literal>, <literal>#poke</literal> and
<literal>#ptr</literal> are not hardwired into the
- <command>hs2c</command>, but are defined in a C template that is
+ <command>hsc2hs</command>, but are defined in a C template that is
included in the C program: <filename>template-hsc.h</filename>.
Custom constructs and templates can be used too. Any
<literal>#</literal>-construct with unknown key is expected to