|
SWIG/Examples/tcl/simple/
Simple Tcl Example$Header: /cvs/projects/SWIG/Examples/tcl/simple/index.html,v 1.1 2000/06/17 21:41:01 beazley Exp $This example illustrates how you can hook Tcl to a very simple C program containing a function and a global variable. The C CodeSuppose you have the following C code:/* File : example.c */ /* A global variable */ double Foo = 3.0; /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g; g = y; while (x > 0) { g = x; x = y % x; y = g; } return g; } The SWIG interfaceHere is a simple SWIG interface file:/* File: example.i */ %module example extern int gcd(int x, int y); extern double Foo; Compilation
Using the extensionClick here to see a script that calls our C functions from Tcl.Key points
|