473,287 Members | 1,927 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

SWIG-PYTHON -> Problem in header file inclusion

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*/
>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 {
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.

Oct 19 '07 #1
0 1691

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: mead | last post by:
This is from an article: "Given a.h and a.cpp files, a.h has been included as the first header file in a.cpp. This will make sure that a.h does not expect a certain header files to be included...
4
by: s.subbarayan | last post by:
Dear all, How different is a header file from a library file in C?Under what circumstance u go for library and under what circumstance u go for header?Afaik,both have some declarations which can...
18
by: Al | last post by:
I'm still trying to do this but it never worked! In a .cpp file, I write the code, and at the beginning, I write: #ifndef MYLIST_H #define MYLIST_H ....to end: #endif What's wrong with it for...
6
by: techBoy | last post by:
I am looking for a tool that can scan my soyrce code and check if a header file gets included more then once in a sequece of compiled code. Can some one guide me to such a tool !!
4
by: shaky | last post by:
i want the explanation for this with example
0
by: abarun22 | last post by:
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...
5
by: Rahul | last post by:
Hi, I often include the header files like the following, #include <string.h> However, i get a warning from the compiler to remove the .h and it works fine with the following, #include...
7
by: Parag Mahajan | last post by:
Hi, I would like to know if there is any way / tool available by which we can detect unnecessary header files included in the source files. Regards, Parag.
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.