I'm experimenting with native C extensions in Python. What I'm trying to accomplish now is to pass Bytes buffer from Python to C.
I need to load a binary file from disk and pass that buffer to C extension however I have no clue what types should I use. What I have now is:
Python part:
import ctypes
lib = ctypes.cdll.LoadLibrary("lib.so")
f = open("file.png", "rb")
buf = f.read()
f.close()
lib.func(buf)
C part:
#include <stdio.h>
void func(int buf) {
// do something with buf
}
int buf? It sounds like you might be in over your head trying to interface Python with C here - you might want to get more familiar with C on its own first.