SWIG image
Home Development Mailing Lists Bugs and Patches
Information
What is SWIG?
Compatibility
Features
Tutorial
Documentation
The Bleeding Edge
History
Subversion
Guilty Parties
Projects
Legal Department
Links
Download
SwigWiki
Exits
AllegroCL
C# - Mono
C# - MS .NET
CFFI
CHICKEN
CLISP
Guile
Java
Lua
MzScheme
Ocaml
Perl
PHP
Python
R
Ruby
Tcl/Tk
Our Generous Host
SourceForge logo

SWIG Features

This information is based on the SWIG-1.3.32 release.

Code Generation

SWIG currently generates wrapper code for eighteen different target languages:
  • Allegro CL
  • C#
  • CFFI
  • CLISP
  • Chicken
  • Guile
  • Java
  • Lua
  • Modula-3
  • Mzscheme
  • OCAML
  • 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:
  • Customizated 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 : Thu Nov 15 23:24:28 2007