Код: Выделить всё
// 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"
< /code>
Running swig -python example.iWarning 453: Can't apply (double *IN_ARRAY1,int DIM1). No typemaps are defined.
< /code>
The examples that do work are simple examples from the SWIG website without typemaps:
int fact(int n);
int my_mod(int x, int y);
char *get_time();
< /code>
Structs also work fine in my larger project.
I confirmed that typemaps.i is available to swig (by introducing a typo such as 'trmpaps.i') and observing that it complains.
I did some tests with numpy.i with similar results but don't want to introduce more confusion to this question.
Подробнее здесь: https://stackoverflow.com/questions/797 ... to-a-point
Мобильная версия