我怎样才能生成C包装上使用痛饮C ++ API? [英] How can I generate C wrappers over C++ API using SWIG?

查看:93
本文介绍了我怎样才能生成C包装上使用痛饮C ++ API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想产生超过一些C ++ API使用痛饮Ç包装。

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

从SWIG文档 SWIG和C ++

6.2方法

要包C ++,SWIG采用分层的方法来code一代。在最低水平,SWIG
  产生程序ANSI-C风格的包装的集合。这些包装照顾
  基本类型转换,类型检查,错误处理和其他低级别的细节
  C ++>绑定。这些包装也足以C ++装订成任何目标语言
  支持内置程序。从某种意义上说,你可能会认为这层包装作为
  提供一个C库接口的C ++。

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++.

不过,我没有看到任何选项来做到这一点,而不会产生code在像Python和Ruby等语言使用API​​我怎样才能得到公正的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?

推荐答案

虽然痛饮主枝无法生成C ++ APIÇ包装(在这个问题引述SWIG文档有点误导),有创造了一大口分支在code 2008和现有的谷歌夏天的https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd/它做到了这一点。我已经在这里找到了答案:下使用SWIG ++到C包装(用于FLTK )

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)

这篇关于我怎样才能生成C包装上使用痛饮C ++ API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆