【发布时间】:2011-10-10 13:15:45
【问题描述】:
我无法弄清楚如何访问以下嵌套结构中的数组元素 SubStatus。我似乎确实能够看到第一个元素,但不明白如何强制索引,例如,作为列表。
非常感谢任何帮助。
status.h:
// Data Types
typedef char CHAR; // 8 bits signed
typedef short SHORT; // 16 bits signed
typedef long LONG; // 32 bits signed
typedef unsigned char UCHAR; // 8 bits unsigned
typedef unsigned short USHORT; // 16 bits usigned
#define FUNC_TYPE // built in C, leave reference as C
#define DLL_API extern FUNC_TYPE __declspec(dllimport)
// Sub Status Data
typedef struct
{
LONG xyz;
LONG abc;
} SUB_STATUS;
// Status Info
typedef struct
{
UCHAR qrs;
UCHAR tuv;
SUB_STATUS SubStatus[4];
LONG wxy;
} STATUS;
DLL_API SHORT GetStatus( STATUS *Status );
status.i
%module status
%{
/* Includes the header in the wrapper code */
#include "status.h"
%}
/* Parse the header file to generate wrappers */
%include "windows.i"
%include "typemaps.i"
%include "status.h"
【问题讨论】:
-
感谢 awoodland,但我无法控制 .h 文件,因为它来自供应商的发行版。如果我正确理解了其他解决方案,我必须对 c 源代码进行修改,对吗?我希望得到一个只会影响 .i 文件的答案。
-
您可以在不修改标题的情况下应用它,但它有点棘手。希望稍后我会整理一个示例。
标签: python arrays structure swig