4 ms·
Possible they were just pre-C++11
by scaredginger 4y ago
Possible they were just pre-C++11
- MontyCarloHall 4y agoThis has been possible since C89. See 3.5.2.1 of the C89 rationale [0]. It is architecture/compiler dependent though. This is explicitly acknowledged in the rationale document: “Since some existing implementations, in the interest of enhanced access time, leave internal holes larger than absolutely necessary, it is not clear that a portable deterministic method can be given for traversing a structure field by field.” [0] https://www.lysator.liu.se/c/rat/c5.html https://www.lysator.liu.se/c/rat/c5.html
- scaredginger 4y agoI think they were referring to the default member initializer, a feature added in C++11 not exclusive to bitfields. I couldn't see any reference to anything similar in what you linked (admittedly, I skimmed though). For example: struct X { int defaulted = 1; // 1 is the default member initializer };
- MontyCarloHall 4y ago>I think they were referring to the default member initializer Ah, that would make more sense. The combination of bitfield and default initializer syntax does look especially odd, since both features are rarely used IME. >I couldn't see any reference to anything similar in what you linked Indeed, there is no way to specify default values for a C struct at definition time.