Skip to content

Instantly share code, notes, and snippets.

@retep998
Created November 25, 2016 04:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save retep998/15a4c4843193789b6f4f91445e8f702e to your computer and use it in GitHub Desktop.
Save retep998/15a4c4843193789b6f4f91445e8f702e to your computer and use it in GitHub Desktop.
winapi DST requirements

Need to be able to add dynamically sized arrays as the last field of a type.

#[repr(C)] struct Foo {
    blah: Blah,
    cbSize: DWORD,
    array: [SomeType; N], // This field should be dynamically sized.
}

The user must be able to specify a value for N when creating such a type, but there must only be one such type, so that FFI functions can easily take a *const Foo or *mut Foo.

The user should be able to allocate such a type with relative ease. At a bare minimum it must be possible to easily such a type on the heap, with the size specified at runtime. Ideally it would be allocatable on the stack with a const size. As a pipe dream, it would be neat if it could be allocated on the stack with a runtime size.

I don't really care what the syntax is, as long as it is relatively sane. It's fine if it requires unsafe.

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