Initial C module file and simple example added.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@10501 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Maciej Drwal 2008-05-28 06:25:25 +00:00
commit 338347feb0
9 changed files with 220 additions and 0 deletions

View file

@ -0,0 +1,12 @@
TOP = ../..
SWIG = $(TOP)/../preinst-swig
SRCS = example.c
TARGET = example
INTERFACE = example.i
EXEC = main.c
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' EXEC='$(EXEC)' c

View file

@ -0,0 +1,18 @@
/* 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;
}

View file

@ -0,0 +1,6 @@
/* File : example.i */
%module example
%inline %{
extern int gcd(int x, int y);
%}

8
Examples/c/simple/main.c Normal file
View file

@ -0,0 +1,8 @@
#include <stdio.h>
int main(int argc, char **argv) {
int a = 35;
int b = 15;
printf("GCD(%d, %d)=%d", a, b, gcd(a, b));
}