英文:
C++: Is there a case when a struct can have different sizes depending on the endianness?
问题
我在一本教材上看到,当字节序更改时,结构体的大小可能会发生变化。我不确定,但我认为示例是
struct X { int a, char b };
请有人解释一下这是否正确?
英文:
So I read on a textbook that there are specific cases when the struct can change sizes when the endianness is changed. I am not sure, but I think that the example was
struct X { int a, char b };
Can someone explain if this is true ?
答案1
得分: 1
A change in endianness means you are on a different system where the compiler is free to define padding, integer size and byte size which could all lead to a different struct size, but it would not be because of the endianness.
英文:
A change in endianness means you are on a different system where the compiler is free to define padding, integer size and byte size which could all lead to a different struct size, but it would not be because of the endianness.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论