Skip to content

Commit 1c8db40

Browse files
authored
Merge pull request godotengine#1958 from dsnopek/rid-alignment
Fix alignment on `RID` and other classes that use `uint8_t opaque[SIZE]`
2 parents 27d7ad0 + 45f45e8 commit 1c8db40

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

binding_generator.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,10 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
768768

769769
result.append(f"class {class_name} {{")
770770
result.append(f"\tstatic constexpr size_t {snake_class_name}_SIZE = {size};")
771-
result.append(f"\tuint8_t opaque[{snake_class_name}_SIZE] = {{}};")
771+
# We don't get alignment information from the JSON so we have to guess.
772+
# This logic should be correct for all built-in types as they exist right now.
773+
alignment = 8 if size >= 8 else 4
774+
result.append(f"\talignas({alignment}) uint8_t opaque[{snake_class_name}_SIZE] = {{}};")
772775

773776
result.append("")
774777
result.append("\tfriend class Variant;")

0 commit comments

Comments
 (0)