← Back to context

Comment by dfawcus

2 months ago

Designated initialisers and compound literals, sure they have caught on, one just has to know where to look:

    https://github.com/danos/vyatta-dataplane/blob/master/src/npf/config/gpc_hw.c#L600-L623

    https://github.com/danos/vyatta-dataplane/blob/master/src/npf/config/npf_rule_group.c#L252-L280

That is code which is around 4 years old.

For the latter example, one could theoretically avoid declaring the variables 'event' an 'rg_match', instead direcly including the compound literals in the respective function calls. However it is a question of taste, and what is more readable.

(The above have designated initialisers, I'm can't remember if there are any compound literal examples there.

There is however one here, when the BSTR_K macro is also expanded, also the earlier BSTR_INIT:

    https://github.com/danos/vyatta-dataplane/blob/master/src/npf/bstr.h#L199