Giter Site home page Giter Site logo

Comments (7)

xlab avatar xlab commented on July 17, 2024 1

Hi! I searched for ways to autogenerate C wrappers for C++ code but couldn't find any. This makes me sad, because it forces me to find somebody who already done any C wrapper and use that work, or create my own from scratch, which is very tedious.

For example, there is Box2D https://github.com/erincatto/Box2D, and luckily it doesn't update too frequently. It means that these C wrappers https://github.com/nical/box2d.rs/tree/master/c/src/Box2D/Dynamics still can be used to generate bindings and they won't be outdated. Sometimes authors of good C++ libraries provide and maintain C API.

If I had time, it's actually possible to write some wrapper generator for C++ using LLVM API, but that's another story.

from c-for-go.

Akagi201 avatar Akagi201 commented on July 17, 2024 1

PS: I am also interested in building a tool that can auto generate C wrappers for C++ code. Haha. Hope I can make one some day.

from c-for-go.

xlab avatar xlab commented on July 17, 2024 1

@Akagi201 Thanks, cgen looked very promising but broke my heart once again. It fails to parse Box2D headers which are simple as hell. This is actually problem of all Haskell translators —

  1. Tries to be as generalised as possible;
  2. Fails on almost any real-world case scenario;
  3. Can't be patched by any other community because it's Haskell.

:(

from c-for-go.

xlab avatar xlab commented on July 17, 2024 1

@Akagi201 Yeah, something like this can be re-written in Go using Clang bindings (300 lines of code lol). Then add some configuration options (currently, the headers and class names are hard-coded) and some prettifying logic. https://github.com/go-clang/v3.9

This CPP2C example, once patched to include proper class names, works fine on Box2D code. LLVM is very, very handy there.

from c-for-go.

xlab avatar xlab commented on July 17, 2024

Maybe https://github.com/EricssonResearch/openwebrtc?

from c-for-go.

Akagi201 avatar Akagi201 commented on July 17, 2024

@xlab I found one interesting project to generate C header from CPP headers. https://github.com/anttisalonen/cgen

You may have to look.

from c-for-go.

Akagi201 avatar Akagi201 commented on July 17, 2024

Found another POC here. https://github.com/samanbarghi/CPP2C

from c-for-go.

Related Issues (20)

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.