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.




_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to