Coder Social home page Coder Social logo

c2hsc's Introduction

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__ \
    libgit2/include/git2/tree.h

Known issues:

  • Need to output vararg functions with a comment mentioning they are not translatable to the Haskell FFI

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.

c2hsc's People

Contributors

aavogt avatar bsl avatar cap11235 avatar flip111 avatar flyfish30 avatar gelisam avatar gloaming avatar jwiegley avatar knsd avatar merijn avatar woehr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.