Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ to C Wrapper using SWIG (for FLTK)

I need to generate wrapper to FLTK C++ classes to use it in pure C. I know, that SWIG can do that, and I know how to generate wrapper for C#, Python etc. But I do not know how to wrap C++ to C using SWIG. It's simple task, but I can't find the answer :) Please, help.

like image 638
Artem Avatar asked Dec 28 '10 15:12

Artem


People also ask

What is SWIG binding?

In a nutshell, SWIG is a compiler that takes C declarations and creates the wrappers needed to access those declarations from other languages including including Perl, Python, Tcl, Ruby, Guile, and Java.

How SWIG works?

SWIG is a software development tool that simplifies the task of interfacing different languages to C and C++ programs. In a nutshell, SWIG is a compiler that takes C/C++ declarations and creates the wrappers needed to access those declarations from other languages including Perl, Python, Tcl, Ruby, Guile, and Java.

What is SWIG C++?

SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages. SWIG is used with different types of target languages including common scripting languages such as Javascript, Perl, PHP, Python, Tcl and Ruby.

How does SWIG work in Python?

In a nutshell, SWIG is a compiler that takes C/C++ declarations and creates a wrapper needed to access those declarations from other languages like Python, Tcl, Ruby etc. It normally required no changes in existing code and create an interface within a minute. Building interpreted interface for existing C programs.


1 Answers

I don't think SWIG supports generation of C wrappers out of the box. You always need to specify a target language. In 2008, there was a GSoC project to write a C backend, but that was apparently never completed/incorporated into SWIG.

like image 96
Martin v. Löwis Avatar answered Sep 20 '22 18:09

Martin v. Löwis