2 ms·
Ask HN: Resources for learning to write wrappers to C libraries
My background is in a little python and i'm learning Scheme right now, but whenever I try to create something non-trivial in Scheme I never complete it, because of the non-availability of a wrapper to a C library that I might need for that particular project. My knowledge of C is very rudimentary and hence I'm unable to write the wrapper myself.
If I were able to write a wrapper to the C library, I would be able to complete the projects and probably become better at Scheme (and also in whatever language I decide to learn in the future).
Does anyone know of tutorials or books that are specifically geared towards writing wrappers or something like that?
I tried searching google but didn't find what I was looking for.
- Kliment 17y agoWith Python, there is a well-defined and well-documented C API, as well as support for ctypes. Ctypes allows you to call into C-interfaced libs with very little code. The Python C API allows you to write modules in C that behave like modules in Python. With Scheme, there are multiple implementations and no standard one, but most implementations provide a functionality for calling external code. Here's a nice list: http://community.schemewiki.org/?ffi http://community.schemewiki.org/?ffi Rather than tutorials, I'd start by trying to dissect existing library wrappers and figuring out how they work. This is how I learned to write Python extensions.
- prick 17y agothanks for the tip, i guess that would be the best way.