【问题标题】:Ctypes problem What is the difference between POINTER and pointer?Ctypes问题 POINTER和指针有什么区别?
【发布时间】:2022-06-19 01:39:51
【问题描述】:

我是python ctypes的新手,POINTER()pointer()有什么区别,它们的作用是什么?

【问题讨论】:

  • 您从docs 所说的话中了解到了什么?有什么特别令人困惑的地方吗?
  • 我想知道实际应用

标签: python ctype


【解决方案1】:

POINTER() 创建一个类型。 pointer() 创建一个实例。

例如,在 C 中:

typedef int* PINT;

应该是:

import ctypes
PINT = ctypes.POINTER(ctypes.c_int)

鉴于:

int value = 5;
int* p = &value;

应该是:

import ctypes
value = ctypes.c_int(5)
p = ctypes.pointer(value)

【讨论】:

    猜你喜欢
    • 2019-09-29
    • 1970-01-01
    • 2011-04-04
    • 2010-12-17
    • 2013-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多