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

dart:ffi Void size one byte or unknown #35879

Open
dcharkes opened this Issue Feb 7, 2019 · 3 comments

Comments

2 participants
@dcharkes
Copy link
Contributor

dcharkes commented Feb 7, 2019

Should Void have a size of 1 byte, or an unknown size.

Defining a size would allow the following

Pointer<Void> p = allocate(count: 20);
Pointer<Void> p2 = p.elementAt(10);
sizeOf<Void>(); // returns 1

Keeping Void opaque, not knowing its size would disallow allocate and sizeOf:

Pointer<Void> p = allocate<Int8>(count: 20).cast();
Pointer<Void> p2 = p.offsetBy(10);
sizeOf<Void>(); // throws exception

cc @sjindel-google

@dcharkes dcharkes added this to To do in Dart VM FFI via automation Feb 7, 2019

@dcharkes dcharkes referenced this issue Feb 7, 2019

Open

dart:ffi resolve outstanding design decisions #35764

1 of 11 tasks complete
@sjindel-google

This comment has been minimized.

Copy link
Contributor

sjindel-google commented Feb 7, 2019

We can allow pointer arithmetic on a Pointer<Void> without necessarily allowing allocate and sizeOf.

@dcharkes

This comment has been minimized.

Copy link
Contributor Author

dcharkes commented Feb 7, 2019

We already allow offsetBy on Pointer<Void>.

@sjindel-google

This comment has been minimized.

Copy link
Contributor

sjindel-google commented Feb 7, 2019

Right, I'm just saying that we could allow elementAt as well, for consistency with C.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment