SWIG image
Home Development Mailing Lists Bugs and Patches
Information
What is SWIG?
Compatibility
Features
Tutorial
Documentation
News
The Bleeding Edge
History
Guilty Parties
Projects
Legal Department
Links
Download
SwigWiki
Donate
Affiliations
Software Freedom Conservancy logo
Our Generous Host
Get SWIG at SourceForge.net. Fast, secure and Free Open Source software downloads
Exits
AllegroCL
C# - Mono
C# - MS .NET
CFFI
CHICKEN
CLISP
D
Go language
Guile
Java
Lua
MzScheme/Racket
Ocaml
Octave
Perl
PHP
Python
R
Ruby
Tcl/Tk

SWIG Features

This information is based on the SWIG-2.0.2 release.

Code Generation

SWIG currently generates wrapper code for nineteen different target languages:
  • Allegro CL
  • C#
  • CFFI
  • CLISP
  • Chicken
  • D
  • Go
  • Guile
  • Java
  • Lua
  • Modula-3
  • Mzscheme
  • OCAML
  • Octave
  • Perl
  • PHP
  • Python
  • R
  • Ruby
  • Tcl
  • UFFI
In addition to this, the parse tree can be exported as XML and Lisp s-expressions. Experimental work is also available for a Pike module.

ANSI C

SWIG is capable of wrapping all of ANSI C. Features include:
  • Handling of all ANSI C datatypes.
  • Global functions, global variables, and constants.
  • Structures and unions.
  • Pointers.
  • Arrays and multidimensional arrays.
  • Pointers to functions.
  • Variable length arguments.
  • Typedef.
  • Enums.

ANSI C++

SWIG provides wrapping support for almost all of ANSI C++.
  • All C++ datatypes.
  • References.
  • Pointers to members.
  • Classes.
  • Inheritance and multiple inheritance.
  • Overloaded functions and methods (using dynamic dispatch).
  • Overloaded operators.
  • Static members.
  • Namespaces (including using declarations, aliases, nesting, etc.)
  • Templates
  • Member templates
  • Template specialization and partial specialization.
  • Smart pointers
  • C++ library support for strings and the STL.
The only major C++ feature not currently supported by SWIG is the wrapping of nested classes.

C++ users who rely on advanced template programming techniques (e.g., template meta-programming) should also be aware that SWIG currently requires manual instantiation of all template classes. Therefore, if your application somehow involves the instantiation of 50000 template classes, your mileage might vary.

Preprocessing

SWIG provides a full C preprocessor with the following features:
  • Macro expansion.
  • Automatic wrapping of #define statements as constants (when applicable).
  • Support for C99 (variadic macro expansion).

Customization features

SWIG provides control over most aspects of wrapper generation. Most of these customization options are fully integrated into the C++ type system--making it easy to apply customizations across inheritance hierarchies, template instantiations, and more. Features include:
  • Customized type conversion/marshaling.
  • Exception handling.
  • Class/structure extension.
  • Memory management.
  • Ambiguity resolution.
  • Template instantiation.
  • File import and cross-module linking.
  • Code inclusion, helper function support.
  • Extensive diagnostics (error/warning messages including fine grained warning suppression).
  • Extended SWIG macro handling.

Feedback and questions concerning this site should be posted to the swig-devel mailing list.

Last modified : Sun Mar 16 17:47:11 2014