18

I would like to generate C wrappers over some C++ API using SWIG.

From the SWIG documentation SWIG and C++:

6.2 Approach

To wrap C++, SWIG uses a layered approach to code generation. At the lowest level, SWIG generates a collection of procedural ANSI-C style wrappers. These wrappers take care of basic type conversion, type checking, error handling, and other low-level details of the C++ >binding. These wrappers are also sufficient to bind C++ into any target language that supports built-in procedures. In some sense, you might view this layer of wrapping as providing a C library interface to C++.

However, I don't see any option to do just that, without generating code for using the API in a language like Python, Ruby, etc. How can I get just the C wrappers?

piokuc
  • 25,594
  • 11
  • 72
  • 102

1 Answers1

12

Although the main branch of SWIG cannot generate C wrappers for C++ API (the SWIG documentation quoted in the question is a bit misleading), there is a SWIG branch created during Google Summer of Code 2008 and available at https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd/ which does just that. I have found the answer here: C++ to C Wrapper using SWIG (for FLTK)

Community
  • 1
  • 1
piokuc
  • 25,594
  • 11
  • 72
  • 102
  • 4
    It's worth noting that there was another GSOC project for that this year (2012) as mentioned [here](http://sourceforge.net/news/?group_id=1645&id=309764). It's not complete yet but hopefully it will come to fruition this time. – Milliams Nov 22 '12 at 11:11