基础类型
C变量类型 | Java变量类型 | C#变量类型 | python变量类型 | arkts变量类型 | 备注 |
int | int | int | c_int | number | |
unsigned int | long | uint | c_uint | number | |
short | short | short | c_short | number | |
unsigned short | int | ushort | c_ushort | number | |
long | int | int | c_long | number | 32位系统中,C中的long型占4字节,可以当作int来使用 |
unsigned long | long | uint | c_ulong | number | 32位系统中,C中的long型占4字节,可以当作int来使用 |
long long | long | long | c_longlong | number | C中long long占用8字节,与Java/C#中的long型等价 |
unsigned long long | long long | ulong | c_ulonglong | number | Java中使用需要注意符号 |
float | float | float | c_float | number | |
double | double | double | c_double | number | |
char | char | char | c_char | number | |
unsigned char | byte | byte | c_byte | number | |
void | void | void | None | void |
基本类型数组与指针
C变量类型 | Java变量类型 | C#变量类型 | python变量类型 | arkts变量类型 | 备注 |
int* | int[]/IntByReference | ref int | POINTER(c_int) | Int32Array | |
int[] | int[]/IntByReference | int[] | POINTER(c_int) | Int32Array | |
unsigned int* | int[]/IntByReference | ref uint | POINTER(c_uint) | Uint32Array | Java中没有无符号数,long占8字节,这里不能使用long[],且使用int[]接收后,要注意符号引起的值变化,用long型接收时,需要按位赋值,不能直接用= |
unsigned int[] | int[]/IntByReference | uint[] | POINTER(c_uint) | Uint32Array | 同上 |
short* | short[]/ShortByReference | ref short | POINTER(c_short) | Int16Array | |
short[] | short[]/ShortByReference | ref short | POINTER(c_short) | Int16Array | |
unsigned short* | short[]/ShortByReference | ref ushort | POINTER(c_ushort) | Uint16Array | |
unsigned short[] | short[]/ShortByReference | ushort[] | POINTER(c_ushort) | Uint16Array | |
long* | int[]/IntByReference | ref int | POINTER(c_int) | Int32Array | 32位系统中,C中的long型占4字节,可以当作int来使用 |
long[] | int[]/IntByReference | int[] | POINTER(c_int) | Int32Array | 32位系统中,C中的long型占4字节,可以当作int来使用 |
unsigned long* | int[]/IntByReference | ref uint | POINTER(c_uint) | Uint32Array | |
unsigned long[] | int[]/IntByReference | uint[] | POINTER(c_uint) | Uint32Array | |
long long* | long[]/LongByReference | ref long | POINTER(c_longlong) | BigInt64Array | C中long long占用8字节,与Java/C#中的long型等价 |
long long[] | long[]/LongByReference | long[] | POINTER(c_longlong) | BigInt64Array | |
unsigned long long* | long[]/LongByReference | ref ulong | POINTER(c_ulonglong) | BigUint64Array | Java中使用需要注意符号 |
unsigned long long | long[]/LongByReference | ulong[] | POINTER(c_ulonglong) | BigUint64Array | Java中使用需要注意符号 |
float* | float[]/FloatByReference | ref float | POINTER(c_float) | Float32Array | |
float[] | float[]/FloatByReference | float[] | POINTER(c_float) | Float32Array | |
double* | double[]/DoubleByReference | ref double | POINTER(c_double) | Float64Array | |
double[] | double[]/DoubleByReference | double[] | POINTER(c_double) | Float64Array | |
char* | char[]/String/CharByReference | ref char/string | c_char_p | Int8Array | |
char[] | char[]/String/CharByReference | ref char/string | c_char_p | Int8Array | |
unsigned char* | byte[]/ByteByReference | ref byte | POINTER(c_ubyte) | Uint8Array | |
unsigned char[] | byte[]/ByteByReference | byte[] | POINTER(c_ubyte) | Uint8Array | |
void* | IntPtr | IntPtr | c_void_p | - | arkts目前没有查到资料,后续复杂类型里再介绍 |
坑开了,一直没有时间去写,今天抽空发个第一篇吧,由于基础变量类型比较简单,各语言调用的示例就不写太多了,arkts需要和napi层联动。另外,arkts中用到数组的地方,都可以直接使用ArrayBuffer,根据需要自行选择即可,使用数组需要双倍内存,ArrayBuffer是直接传地址过去,napi层获取是,如果参数类型是ArrayBuffer就不需要去获取数组相关的信息了,直接对array_buffer的地址操作即可。
标签:short,int,基础,unsigned,long,char,类型,POINTER,指针 From: https://blog.csdn.net/geesehoward20000/article/details/143711700