From 1a13842f7ece9f3c492a7017509b75eafa903bbf Mon Sep 17 00:00:00 2001 From: "Nathan V. Morrical" Date: Wed, 17 Jan 2024 15:34:51 -0800 Subject: updated docs to more clearly define differences in sizeof(bool) depending on the target platform (#3458) Co-authored-by: Yong He --- docs/user-guide/02-conventional-features.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/user-guide/02-conventional-features.md b/docs/user-guide/02-conventional-features.md index ebf4c1ca7..6c6198d90 100644 --- a/docs/user-guide/02-conventional-features.md +++ b/docs/user-guide/02-conventional-features.md @@ -54,7 +54,19 @@ All targets support the 32-bit `float`, but support for the other types depends ### Boolean Type -The type `bool` is used to represent Boolean truth value: `true` and `false`. +The type `bool` is used to represent Boolean truth value: `true` and `false`. + +For compatibility reasons, the `sizeof(bool)` depends on the target. + +| Target | sizeof(bool) | +|--------| ---------------------- | +| GLSL | 4 bytes / 32-bit value | +| HLSL | 4 bytes / 32-bit value | +| CUDA | 1 bytes / 8-bit value | + +> #### Note #### +> When storing bool types in structures, make sure to either pad host-side data structures accordingly, or store booleans as, eg, `uint8_t`, to guarantee +> consistency with the host language's boolean type. #### The Void Type -- cgit v1.2.3