[Tutor] Get the structure values from a c file
Marefe Serentas
marszydril at gmail.com
Mon Dec 17 04:12:45 CET 2012
Hi, I need help.
I want to create a python script that will store the value of the
structure /MainStruct/ from the c file.
Suppose my c file looks like this:
----------------------------------------------------------
#define max (3)
typedef struct A
{
int a;
char b;
}A;
typedef struct MainStruct
{
A var1;
int var2;
int var3[max];
}Main;
void generate()
{
MainStruct myMain = {0};
myMain.var1.a = 1
myMain.var1.b = 'a'
myMain.var2 = 3
myMain.var3[0] = -3
myMain.var3[1] = 6
myMain.var3[2] = 18
}
-------------------------------------------------------------
My python script accepts a c file as input.
How can I get the values of the structure?
Can I call the function generate() in python script, but it doesn't have
a return statement, how can I get the values by calling the function?
Help me, I'm really new in python.
All I could think is just parse the c file. But it seems that it's not a
good idea.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20121217/65777cb6/attachment.html>
More information about the Tutor
mailing list