The c2hsc package

[Tags: bsd3, program]

Convert C API header files to .hsc and .hsc.helper.c files

[Skip to ReadMe]


Versions0.1.0, 0.2.0, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.4.0, 0.5.0, 0.5.1, 0.6.2, 0.6.3, 0.6.4, 0.6.5
Change logNone available
Dependenciesbase (==4.*), cmdargs (>=0.9), containers (>=0.4), directory (>=1.1), filepath (>=1.3), HStringTemplate (>=0.6), language-c (>=0.4), mtl (>=2.0), pretty (>=1.1), split (>=0.2), transformers (>=0.2) [details]
AuthorJohn Wiegley
MaintainerJohn Wiegley <>
Home page
Source repositoryhead: git clone
UploadedMon Jan 20 07:08:53 UTC 2014 by JohnWiegley
Downloads2826 total (26 in last 30 days)
0 []
StatusDocs not available [build log]
Last success reported on 2015-12-10 [all 6 reports]


Maintainers' corner

For package maintainers and hackage trustees

Readme for c2hsc-0.6.4

Converts C API header files to .hsc and .hsc.helper.c files

Usage: c2hsc --prefix=<Lib Prefix> <FILE>.h

This will create <FILE>.hsc, and <FILE>.hsc.helper.c if the header file contains inline functions.

For example, in hlibgit2 on the Mac I'm using:

c2hsc --prefix=Bindings.Libgit2 --cppopts=-U__BLOCKS__ \

Known issues:

Also, please note that this tool will never be 100% accurate. It cannot translate macros, or anything related to the preprocessor, for example. It often misses necessary #include files, and will get them wrong in any case if preprocessor conditionals are involved.

The goal of c2hsc is to solve the hardest 80% of the problem of creating an FFI library. The remaining 20%, plus validation of the results, is an exercise necessarily left to the user.