I came across some C code with an unusual structure initialization syntax.
struct spi_ioc_transfer tr = {
.tx_buf = (unsigned long)tx,
.rx_buf = (unsigned long)rx,
.len = ARRAY_SIZE(tx),
.delay_usecs = delay,
.speed_hz = speed,
.bits_per_word = bits,
};
First off, I have no idea what this is called. What is this known as? Perhaps "dot initialisation syntax" as I suggested in the question title? I have not encountered this before so I don't know how to describe it.
Secondly, this is valid C code as it compiles, however what dialect of C is this and when was it introduced? (Was it new in C11?)
Thirdly, if some members of the struct are omitted, are those members initialized to zero. If not, is there a way to initialize the struct such that omitted members are zero.
(For example spi_ios_transfer
also contains a field cs-change
which has been omitted here.)
Finally is this permitted also in C++, and does it work with C++ classes?