[Haskell-beginners] parse C header files and transformation

Ted Feng artisdom at gmail.com
Mon Mar 4 13:33:08 CET 2013


Hello list,

How to do some C header files parsing and automatic code transformation.

like:

parse this <sys/time.h> header file, and generate code for this API:

int gettimeofday(struct timeval *tv, struct timezone *tz);

generated code(automatically call the API, and dump the structure
appropriately):

void dump_time(void)
{
    struct timeval tv = {0};
    struct timezone tz = {0};

    gettimeofday(&tv, &tz);
    printf("tv_sec: %d, tv_usec: %d\n", tv.tv_sec, tv.tv_usec);
    printf("tz_minuteswest: %d, tz_dsttime: %d\n", tz.tz_minuteswest,
tz.tz_dsttime);
}

because I'm working on a SDK which has hundreds of API to set and get
headware states.
It'll will be very nice to write some haskell code to parse the header
files and generate C code
that can dump hardware state automatically.

BR
Ted
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130304/53baaa53/attachment.htm>


More information about the Beginners mailing list