Код: Выделить всё
// example.c
#include
#include "example.h"
double rms(double* seq, int n) {
double sum = 0.0;
for (int i = 0; i < n; i++) {
sum += seq[i] * seq[i];
}
return sqrt(sum / n);
}
< /code>
// example.h
#ifndef EXAMPLE_H
#define EXAMPLE_H
double rms(double* seq, int n);
#endif
< /code>
// example.i
%module example
%include "typemaps.i"
%{
#include "example.h"
%}
%apply (double *IN_ARRAY1, int DIM1) { (double *seq, int n) };
%include "example.h"
Код: Выделить всё
Warning 453: Can't apply (double *IN_ARRAY1,int DIM1). No typemaps are defined.
< /code>
Примеры, которые выполняют работу, являются простыми примерами с веб-сайта SWIG без TypeMaps: < /p>
int fact(int n);
int my_mod(int x, int y);
char *get_time();
Подробнее здесь: https://stackoverflow.com/questions/797 ... -a-pointer
Мобильная версия