Skip to content

[docs/ffi] .address position should mention .cast() #56613

Open
@codesculpture

Description

@codesculpture

TODO

  • The dartdoc comment of .address should mention or show an example of using .cast().
  • The published ADDRESS_POSITION documentation should mention .cast().

Original bug report:

While trying to fix this,
I found the below code is

@Native<Void Function(Pointer<Void>)>(isLeaf: true)
external void myNative(Pointer<Void> buff);

void main() {
  final buff = Int8List.fromList([2]);
  myNative(buff.address.cc);
}

throws 2 errors by the analyzer

1. ERROR|COMPILE_TIME_ERROR|ADDRESS_POSITION|9|17|7|The '.address' expression can only be used as argument to a leaf native external call.
2. ERROR|COMPILE_TIME_ERROR|UNDEFINED_GETTER|9|25|2|The getter 'cc' isn't defined for the type 'Pointer<Int8>'.

But expected is only one error

1. ERROR|COMPILE_TIME_ERROR|UNDEFINED_GETTER|9|25|2|The getter 'cc' isn't defined for the type 'Pointer<Int8>'.

FYI @dcharkes

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestarea-documentationPrefer using 'type-documentation' and a specific area label.library-ffitype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions