Jump to content

Memory layout of a data structure: Difference between revisions

Fixed second D entry
(→‎{{header|Pascal}}: add example)
(Fixed second D entry)
Line 112:
 
=={{header|D}}==
===Tango version===
Implementation uses tango's BitArray structure.
{{libheader|tango}}
Line 190 ⟶ 191:
[RD:0, RI:1, DSR:1, SG:1, DTR:1, TC:1, TD:1, CD:1, SQD:1, +:1, -:1, SRD:1, RTS:1, SRS:1, STD:1, PG:1, SCD:1, CTS:0, DRS:1, SCS:1, XTC:1, RC:1 ]
</pre>
===Phobos version===
Using Phobos (not tested, possibly wrong):
Not tested.
<lang d>import std.bitmanip;
 
struct RS232_data {
static if (std.system.endian == std.system.Endian.BigEndianbigEndian) {
mixin(bitfields!(bool, "carrier_detect", 1,
bool, "received_data", 1,
Line 217 ⟶ 219:
bool, "carrier_detect", 1));
}
 
static assert(RS232_data.sizeof == 2);
}
 
void main() {}</lang>
}</lang>
 
=={{header|Forth}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.