SWIG-PYTHON -> Problem in header file inclusion

A

abarun22

Hi
I am facing a problem while including a C header file in the SWIG
interface file. However the problem does not occur when i directly
copy the contents of header file in the same place.

My interface file read as follows.
/* interface file dep.i */
%module dep
%{
#include "dep.h"
%}
%inline %{
extern int ReadDep (char* fname, DONfic* don, int nb2, int nb4);
%}

And my header file consists of the structure DONfic as shown below.
/* Header file dep.h */
typedef struct _DONfic {
int nb_dep, nb_inc_dep, ncasec_dep;
int max_dep;
} DONfic;
From python i tried to access the C structure as a python class as
shown below.
/* File pydep.py*/Gives the following error message

Traceback (most recent call last):
File "pydep.py", line 5, in ?
d = dep.DONfic()
AttributeError: 'module' object has no attribute 'DONfic'
The problem is that i cannot get access to the structure if i directly
include the file "dep.h". On the other hand if i copy the contents of
the header file and paste it directly in to the header section of the
SWIG interface file it works.
It works for the following interface file .
%module dep
%{
typedef struct _DONfic {
int nb_dep, nb_inc_dep, ncasec_dep;
int max_dep;
} DONfic;
%}
%inline %{
extern int ReadDep (char* fname, DONfic* don, int nb2, int nb4);
%}


I tried out lot of options and does n't seems to work. Any suggestions
or ideas are most welcome.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top