Skip to content

packed structs #183

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

Closed
andrewrk opened this issue Sep 5, 2016 · 0 comments
Closed

packed structs #183

andrewrk opened this issue Sep 5, 2016 · 0 comments
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase.

Comments

@andrewrk
Copy link
Member

andrewrk commented Sep 5, 2016

Packed structs have these properties different than ordinary structs:

  • Field order is specified by programmer.
  • Field size is specified by programmer.
  • Alignment is explicitly specified.

Syntax proposal 1 - attribute:

#attribute("packed")
struct Foo {
    // ...
}

Syntax proposal 2 - keyword:

packed struct Foo {
    // ...
}

It may also be nice to have a way for the programmer to annotate constraints that if violated become compile errors. For example:

  • Struct size must be a power of 2, or a multiple of 4.

That's the only example I could think of. And this can be accomplished with

const _ = if (@sizeOf(Foo) % 4 != 0) @compileError("sizeof foo must be multiple of 4") else void;
@andrewrk andrewrk added the enhancement Solving this issue will likely involve adding new logic or components to the codebase. label Sep 5, 2016
ianic added a commit to ianic/zig that referenced this issue Nov 8, 2023
Unsupported tests are now skipped on kernel 5.4:
```
uname -a
Linux d20 5.4.0-166-generic ziglang#183-Ubuntu SMP Mon Oct 2 11:31:37 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux
zig test lib/std/std.zig --zig-lib-dir lib --main-mod-path lib/std 2>&1 | cat
709/2616 test.nop... OK
710/2616 test.readv... OK
711/2616 test.writev/fsync/readv... OK
712/2616 test.write/read... SKIP
713/2616 test.splice/read... SKIP
714/2616 test.write_fixed/read_fixed... OK
715/2616 test.openat... SKIP
716/2616 test.close... SKIP
717/2616 test.accept/connect/send/recv... SKIP
718/2616 test.sendmsg/recvmsg... OK
719/2616 test.timeout (after a relative time)... SKIP
720/2616 test.timeout (after a number of completions)... OK
721/2616 test.timeout_remove... SKIP
722/2616 test.accept/connect/recv/link_timeout... SKIP
723/2616 test.fallocate... SKIP
724/2616 test.statx... SKIP
725/2616 test.accept/connect/recv/cancel... SKIP
726/2616 test.register_files_update... SKIP
727/2616 test.shutdown... SKIP
728/2616 test.renameat... SKIP
729/2616 test.unlinkat... SKIP
730/2616 test.mkdirat... SKIP
731/2616 test.symlinkat... SKIP
732/2616 test.linkat... SKIP
733/2616 test.provide_buffers: read... SKIP
734/2616 test.remove_buffers... SKIP
735/2616 test.provide_buffers: accept/connect/send/recv... SKIP
736/2616 test.accept multishot... SKIP
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase.
Projects
None yet
Development

No branches or pull requests

1 participant