diff options
author | Eric Seppanen <eds@reric.net> | 2021-07-16 12:22:02 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-16 21:22:02 +0200 |
commit | 67538b64ea1b90a0d01e4f6ebd45713ec03c9222 (patch) | |
tree | edde7c4ec2744b0221eebaea2e40125d9d441076 /tests/headers/explicit-padding.h | |
parent | 14a8d29baa1da364c6f33de42c4048ed573b06ed (diff) |
Allow explicit padding (#2060)
If a struct needs to be serialized in its native format (padding bytes
and all), for example writing it to a file or sending it on the network,
then explicit padding fields are necessary, as anything reading the
padding bytes of a struct may lead to Undefined Behavior.
Diffstat (limited to 'tests/headers/explicit-padding.h')
-rw-r--r-- | tests/headers/explicit-padding.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/headers/explicit-padding.h b/tests/headers/explicit-padding.h new file mode 100644 index 00000000..d228961d --- /dev/null +++ b/tests/headers/explicit-padding.h @@ -0,0 +1,11 @@ +// bindgen-flags: --explicit-padding + +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; + +struct pad_me { + uint8_t first; + uint32_t second; + uint16_t third; +}; |