[Haskell-beginners] Recursive macros in hsc2hs

Antoine Latter aslatter at gmail.com
Tue Jul 14 23:28:19 EDT 2009


On Tue, Jul 14, 2009 at 9:51 PM, Maurí­cio<briqueabraque at yahoo.com> wrote:
> I'm trying to define a macro inside a template that generates
> an existing macro:
>
> ---
>
> #define hsc_test(hst,ct) \
>    { \
>        printf("#def inline int b_%s(void){return %s;}\n", hst,ct); \
>        printf("foreign import ccall b_%s :: CInt\n", hst); \
>    }
>
> ---
>
> Contrary to my expectation, the '#def' construct printed at the
> first 'printf' is included in the final haskell file, instead of
> beeing removed and replaced by a C function definition in a c
> header file.
>

I thought CPP igored tokens occurring in strings? So CPP wouldn't even
see the #define in the argument to printf.

I'm not a C wizard, but I though that's how it worked.

Antoine


More information about the Beginners mailing list