RosettaCodeData/Task/Memory-layout-of-a-data-structure/D/memory-layout-of-a-data-structure-2.d
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07:00

31 lines
1.3 KiB
D

import std.bitmanip;
struct RS232_data {
static if (std.system.endian == std.system.Endian.bigEndian) {
mixin(bitfields!(bool, "carrier_detect", 1,
bool, "received_data", 1,
bool, "transmitted_data", 1,
bool, "data_terminal_ready", 1,
bool, "signal_ground", 1,
bool, "data_set_ready", 1,
bool, "request_to_send", 1,
bool, "clear_to_send", 1,
bool, "ring_indicator", 1,
bool, "", 7));
} else {
mixin(bitfields!(bool, "", 7,
bool, "ring_indicator", 1,
bool, "clear_to_send", 1,
bool, "request_to_send", 1,
bool, "data_set_ready", 1,
bool, "signal_ground", 1,
bool, "data_terminal_ready", 1,
bool, "transmitted_data", 1,
bool, "received_data", 1,
bool, "carrier_detect", 1));
}
static assert(RS232_data.sizeof == 2);
}
void main() {}