[Haskell-cafe] A question regarding reading CPP definitions from a C header

Ömer Sinan Ağacan omeragacan
Mon Oct 7 19:20:52 UTC 2013


Thanks for your answer, looks like this is my only option to do this.

Can you provide some information about what does parameters of
runCpphsReturningSymTab stands for? I made several attempts but
couldn't get any useful return value.

For example, I have no idea what does third parameter does. Also,
second parameter.

Thanks,

---
?mer Sinan A?acan
http://osa1.net


2013/10/7 Malcolm Wallace <malcolm.wallace at me.com>:
> If you use cpphs as a library, there is an API called runCpphsReturningSymTab.  Thence you can throw away the actual pre-preprocessed result text, keep only the symbol table, and lookup whatever macros you wish to find their values.  I suggest you make this into a little code-generator, to produce a Haskell module containing the values you need.
>
> On 5 Oct 2013, at 21:37, ?mer Sinan A?acan wrote:
>
>> Hi all,
>>
>> Let's say I want to #include a C header file in my Haskell library
>> just to read some macro definitions. The C header file also contains
>> some C code. Is there a way to load only macro definitions and not C
>> code in #include declarations in Haskell?
>>
>> What I'm trying to do is I'm linking my library against this C library
>> but I want to support different versions of this C library, so I want
>> to read it's version from one of it's header files. The problem is the
>> header file contains some C code and makes my Haskell source code
>> mixed with C source before compilation.
>>
>> Any suggestions would be appreciated,
>




More information about the Haskell-Cafe mailing list