python中定义变量typedef_如何通过Python和ctype访问C全局变量结构

本文介绍了如何在Python中通过ctype库访问C语言编译的动态链接库(.so文件)中的全局变量结构。示例代码展示了如何初始化C库函数,并使用`in_dll`方法正确地访问并修改C全局结构变量的值。
摘要由CSDN通过智能技术生成

I have to integrate python with external so library. Unfortunately, the C code uses a global variable SimpleTest_Y (structure) and I need to access it in order to modify the value(s).

Here the C code

SimpleTest.c file

#include "SimpleTest.h"

/* External inputs (root inport signals with auto storage) */

ExtU_SimpleTest_T SimpleTest_U;

/* External outputs (root outports fed by signals with auto storage) */

ExtY_SimpleTest_T SimpleTest_Y;

/* Model initialize function */

void SimpleTest_initialize(void)

{

/* external outputs */

SimpleTest_Y.Out1 = 3.0;

}

SimpleTest.h file

#ifndef SimpleTest_COMMON_INCLUDES_

# define SimpleTest_COMMON_INCLUDES_

#include

#include

#endif

/* External inputs (root inport signals with

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值