小编dev*_*kim的帖子

SWIG Python C++ 结构作为输入/输出参数

老实说,我在这个网站上阅读并重新阅读了很多有关结构主题的帖子。但我需要你的帮助。

我有 C 风格的结构

   struct Time
   {
      uint16_t  year; //    year with four digits like 2016
      uint8_t   month; // 1 .. 12
      uint8_t   day; // 1 .. 31
      uint8_t   hour; // 0 .. 23, 24 hour representation
      uint8_t   minute; // 0 .. 59
      uint8_t   second; // 0 .. 59
   };
Run Code Online (Sandbox Code Playgroud)

以及带有成员函数的类,其实现在DLL中。

class DeviceInterface {
virtual uint32_t getTime(Time&  time) = 0;
};
Run Code Online (Sandbox Code Playgroud)

其中uint32_t值是状态代码。

这是自动生成的 SWIG C++ 代码:

SWIGINTERN PyObject *_wrap_getTime(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
  PyObject *resultobj = …
Run Code Online (Sandbox Code Playgroud)

c++ python swig struct

3
推荐指数
1
解决办法
1143
查看次数

标签 统计

c++ ×1

python ×1

struct ×1

swig ×1