-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to define a type like size_t?? #39372
Comments
You can use ffi.IntPtr for this. However, I think it gets sign extended on both 32-bit and 64-bit machines. |
I find some package is use Int32 like this: tflite_native, method: |
@x-liang The TFLite one seems like a bug. It should be IntPtr, otherwise if the size is greater than 2gb the return result will be incorrect. |
It's not possible to define your own native type that way. We keep track of a list of requested types here: #36140. Though, we can only add those types if they are well-defined across a range of compilers/platforms. |
We've filed an issue for implementing a generic solution for this #42563. |
JavaScriptCore has a API is
JSStringGetLength
it need a JSStringRef and return asize_t
type value.size_t : if the compiler is 32 bit then it is simply a typedef(i.e., alias) for unsigned int but if the compiler is 64 bit then it would be a typedef for unsigned long long. The size_t data type is never negative.
dart.ffi has ffi.Uint32, ffi.Uint64, witch type should I use to map size_t? If I use ffi.Uint64 it has a out of bound problem is 32bit machine. I think this problem because in 32bit matchine C API return a 32bit size value, but ffi.Pointer it will find UInt64 size value. If I use Uint32 in 64bit matchine when the return value is so large may be out of bound.
How to define a type in 32bit matchine is Uint32 and 64bit is Uint64 like size_t??
The text was updated successfully, but these errors were encountered: