开发者

Mapping basic typedef aliases with ctypes?

开发者 https://www.devze.com 2023-03-10 23:10 出处:网络
I understand how to define structs in Python with ctypes, but I can\'t seem to find any documentation on how to handle basic aliases. For example 64-bit integers in SQLite:

I understand how to define structs in Python with ctypes, but I can't seem to find any documentation on how to handle basic aliases. For example 64-bit integers in SQLite:

#ifdef SQLITE_INT64_TYPE
  typedef SQLITE_INT64_TYPE sqlite_int64;
  typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
#elif defined(_MSC_VER) || defined(__BORLANDC__)
  typedef __int64 sqlite_int64;
  typedef unsigned __int64 sqlite_uint64;
#else
  typedef long long int sqlite_int64;
  t开发者_运维问答ypedef unsigned long long int sqlite_uint64;
#endif
typedef sqlite_int64 sqlite3_int64;
typedef sqlite_uint64 sqlite3_uint64;

Depending on the build options, the basic type is different. In this case, I think I can make an assumption that the type is c_longlong, but is that the correct way to handle this situation?


While this certainly isn't the 'correct' way to handle this, short of using the C API instead of ctypes, this is the only solution. By the time ctypes runs, the typedef information has been removed - it doesn't appear as symbols in the compiled library.

0

精彩评论

暂无评论...
验证码 换一张
取 消