I've written plenty of C before, but I don't recognize this syntax:
static const char *names[] = {
[BOND_MODE_ROUNDROBIN] = "load balancing (round-robin)",
[BOND_MODE_ACTIVEBACKUP] = "fault-tolerance (active-backup)",
[BOND_MODE_XOR] = "load balancing (xor)",
[BOND_MODE_BROADCAST] = "fault-tolerance (broadcast)",
[BOND_MODE_8023AD] = "IEEE 802.3ad Dynamic link aggregation",
[BOND_MODE_TLB] = "transmit load balancing",
[BOND_MODE_ALB] = "adaptive load balancing",
};
The [...] =
part is what looks weird to me. (By the way, BOND_MODE_ROUNDROBIN
and the others are macros which just expand to integers.)
It's called designated initializers, which is introduced in C99. GCC also supports it as an extension.
It's used to initialize structures and arrays, see Designated Initializers for detail.
That is a designated initializer. It allows you to intialize the contents of the array in an arbitrary order.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With