SWIG-PYTHON - Problem in header file inclusion

2007-10-20 Thread 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 {
   intnb_dep, nb_inc_dep, ncasec_dep;
   intmax_dep;
} DONfic;

From python i tried to access the C structure as a python class as
shown below.
/* File pydep.py*/
 import dep
...
 d = dep.DONfic()
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 {
   intnb_dep, nb_inc_dep, ncasec_dep;
   intmax_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.

-- 
http://mail.python.org/mailman/listinfo/python-list


SWIG-PYTHON - Problem in header file inclusion

2007-10-19 Thread 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 {
intnb_dep, nb_inc_dep, ncasec_dep;
intmax_dep;
} DONfic;

From python i tried to access the C structure as a python class as
shown below.
/* File pydep.py*/
 import dep
...
 d = dep.DONfic()
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 {
intnb_dep, nb_inc_dep, ncasec_dep;
intmax_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.

-- 
http://mail.python.org/mailman/listinfo/python-list