Makesdna: more verbose Align struct error

Change the `makesdna` error message from:

```
Align struct error: Bone color
```

to:

```
Align struct error: Bone::color (starts at 180 on the native platform;  180 % 8 = 4 bytes)
```

This has a few advantages:

- The colon notation (`Bone::color`) makes it easier to recognise that this is about a specific struct field.
- It makes it clear that this is about the start/offset of the inner struct.
- It includes the math the check is actually doing, providing concrete information on how to change the code to fix the issue.

Pull Request: https://projects.blender.org/blender/blender/pulls/110291
This commit is contained in:
Sybren A. Stüvel
2023-07-21 12:24:35 +02:00
parent 495a198393
commit 4833dd931b

View File

@@ -1073,7 +1073,15 @@ static int calculate_struct_sizes(int firststruct, FILE *file_verify, const char
/* struct alignment */
if (type >= firststruct) {
if (sizeof(void *) == 8 && (size_native % 8)) {
fprintf(stderr, "Align struct error: %s %s\n", types[structtype], cp);
fprintf(stderr,
"Align struct error: %s::%s (starts at %d on the native platform; "
"%d %% %lu = %d bytes)\n",
types[structtype],
cp,
size_native,
size_native,
sizeof(void *),
size_native % 8);
dna_error = 1;
}
}