summaryrefslogtreecommitdiff
path: root/tests/headers/explicit-padding.h
diff options
context:
space:
mode:
authorEric Seppanen <eds@reric.net>2021-07-16 12:22:02 -0700
committerGitHub <noreply@github.com>2021-07-16 21:22:02 +0200
commit67538b64ea1b90a0d01e4f6ebd45713ec03c9222 (patch)
treeedde7c4ec2744b0221eebaea2e40125d9d441076 /tests/headers/explicit-padding.h
parent14a8d29baa1da364c6f33de42c4048ed573b06ed (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.h11
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;
+};