Closed rogurotus closed 1 year ago
Which version of ffigen are you using?
It sounds very similar to
ffigen: ^7.2.3
size_t works correctly
This reproduces for me
int temp_u() {
return _temp_u();
}
late final _temp_uPtr =
_lookup<ffi.NativeFunction<uintptr_t Function()>>('temp_u');
late final _temp_u = _temp_uPtr.asFunction<int Function()>();
int temp_i() {
return _temp_i();
}
late final _temp_iPtr =
_lookup<ffi.NativeFunction<ffi.IntPtr Function()>>('temp_i');
late final _temp_i = _temp_iPtr.asFunction<int Function()>();
typedef uintptr_t = ffi.UnsignedLong;
It's missing here:
Adding it there works for me.
Would you like to contribute a PR for all types defined in https://github.com/dart-lang/sdk/blob/ff2d661d5ba07766fc27196e98df6c6ae80444b9/sdk/lib/ffi/c_type.dart @rogurotus ?
I will trust it to you
@mannprerak2 What is the difference between cxTypeKindToImportedTypes
, suportedTypedefToSuportedNativeType
, and supportedTypedefToImportedType
in that file? Should they all be unified?
cxTypeKindToImportedTypes
This is for mapping the primitive types in C.
suportedTypedefToSuportedNativeType & supportedTypedefToImportedType
These are for mapping some supported types, such as those defined in #include<stdint.h>
.
These are behind a flag(use-supported-typedefs) in config and can be turned off. We can merge these 2 together by using ImportedType for UInt8, UInt16, etc as well.
Do you want to make the PR? Otherwise I can take a look tomorrow.
I can do it on the weekend if that's fine.
Thanks @mannprerak2 !
@rogurotus I have published v7.2.4 which includes the fix.
I can do it on the weekend if that's fine.
@mannprerak2 I want my weekends when your weekends start! 😄 Thanks! 🎸
@mannprerak2 I want my weekends when your weekends start! 😄 Thanks!
@dcharkes Haha, It's the same, just had some spare time in between meetings. 😃
Hello. I discovered unexpected behavior
temp.h
using ffigen on linux I get this.
for some reason
intptr_t
converts correctly toffi.IntPtr
butuintptr_t
is converted totypedef uintptr_t = ffi.UnsignedLong
; Why isuintptr_t
not converted toffi.UIntPtr
?ffi.UnsignedLong
is 64 for linux but 32 for windows, which causes errors when using generated dart code by linux on windows.