2

I created a C program and choose to use python as my GUI creator I wrote the python GUI and decided to create a struct

typedef struct GUIcommunicator
{
    char action[MAX_SIZE];
    char params[MAX_PARAMS][MAX_SIZE];
}GUIcommunicator;

I using this answer I will return the struct from the python receive him in my C code

but I don't know how. And I'd like to some help

(the function that sends the struct (the python code) already got the action and the params as string list )

3
  • It sounds like you need to call C from Python, not the other way around. Commented Jun 13, 2019 at 23:53
  • I know but I need to retrun answers to the c program Commented Jun 14, 2019 at 6:52
  • @EyalElbaz: Is it returning answers if they’re arguments to a call you’re making? Commented Jun 14, 2019 at 12:57

2 Answers 2

1

If you are developing a linux based application, you can perform Inter-Process Communication using FIFO files

For windows based applications, you could use Named-pipes

Sign up to request clarification or add additional context in comments.

Comments

1

Regardless of the direction of the call, you end up with a PyObject* in C that refers to a list of strings. Fetch each element, then fetch the string data pointer and size for a Python 2 str or (the UTF-8 encoding of) a Python 3 str. Check the size against MAX_SIZE (probably MAX_SIZE-1) and beware of embedded null characters, which your struct presumably cannot represent.

There are of course ways of accepting any iterable, converting elements to strings, etc., if you want that flexibility.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.