#include<iostream>
#include<string.h>
using namespace std;
//该文件名称:cpptest.cpp
//终端下编译指令:
//g++ -o cpptest.so -shared -fPIC cpptest.cpp
typedef unsigned char byte;
struct sub_Struct{
int sub_test_int;
char sub_test_char_arr[300];
};
struct NET_DVR_ALARMER{
int test_int;
char char_array[123];
sub_Struct test_sub_struct;
byte *byte_test_p;
};
typedef void (*Fun)(long,NET_DVR_ALARMER*,void*,char*)

这是一个关于如何使用Python调用C++代码,并实现C++回调到Python的示例。代码展示了如何定义C++结构体,创建回调函数指针类型,以及在Python中使用ctypes库加载C++编译后的动态库。在回调过程中,C++传递了结构体数据到Python,包括嵌套结构体和不同类型的数据。
最低0.47元/天 解锁文章
4706





