c:
/* A global variable */
double Foox = 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;
}
swig.i:
/* File : example.i */
%module example
%inline %{
extern int gcd(int x, int y);
extern double Foox;
%}
swig -python -c++ example.i
g++ -c -fPIC example.c example_wrap.cxx -I/usr/include/python2.7
g++ -shared example.o example_wrap.o -o _example.so
import example