Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> there are types that do have standard layouts

Out of interest (I'm not tracking the C++ standard much these days) such as? For example I know about the order of struct members and bit fields, but that has always been the case in C, and so in C++.




Bitfields are standard, what are you talking about?


How they live inside of a structure is far into implementation-defined land. No ABI (afaik) says where bits live if they do not fill an octet. In practice, the compilers agree with themselves over time, but that is "code as spec" which is everyone's favorite thing for interop.


It's well defined in the system V ABI, isn't it? Compilers do follow that. Otherwise no layout is defined by the C and C++ standards, even outside of bitfields.

edit: It's under "Bit-Fields" in [1]. I'm not entirely happy with the wording, but it's there.

[1] https://raw.githubusercontent.com/wiki/hjl-tools/x86-psABI/x...




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: