SWIG and Automated C/C++ Scripting Extensions

By David Beazley

Dr. Dobb's Journal February 1998

%module stdio
%{
#include <stdio.h>
%}
FILE     *fopen(char *filename, char *mode);
int       fclose(FILE *);
unsigned  fread(void *ptr, unsigned size, unsigned nobj, FILE *);
unsigned  fwrite(void *ptr, unsigned size, unsigned nobj, FILE *);
// Now a few memory allocation functions
void *malloc(unsigned nbytes);
void  free(void *);

Example 3: SWIG interface to a few functions in the stdio library.

Back to Article


Copyright © 1998, Dr. Dobb's Journal