Andrey 2023-04-29 22:08:56 -04:00
parent 5ddbcf56e8
commit 08620bedea
3 changed files with 5 additions and 2 deletions

Binary file not shown.

View File

@ -80,7 +80,10 @@ public class BaseCHeaderConsumer implements ConfigurationConsumer {
}
content.append("};" + EOL);
content.append("static_assert(sizeof(" + structure.getName() + ") == " + iterator.currentOffset + ");\n");
int realSize = iterator.currentOffset;
// https://stackoverflow.com/questions/621616/c-what-is-the-size-of-an-object-of-an-empty-class
int cppSize = Math.max(1, realSize);
content.append("static_assert(sizeof(" + structure.getName() + ") == " + cppSize + ");\n");
content.append(EOL);
}

View File

@ -118,7 +118,7 @@ public class TSProjectConsumerTest {
assertEquals("// start of pid_s\n" +
"struct pid_s {\n" +
"};\n" +
"static_assert(sizeof(pid_s) == 0);\n" +
"static_assert(sizeof(pid_s) == 1);\n" +
"\n", consumer.getContent());
}
}