uncrustify: how to alter the struct initialization braces

220 Views Asked by At

I am using uncrustify 0.69.0 (I can't get 0.71.0 to compile yet). I have the following:

static struct {
    unsigned char streamid[2];
    uint32_t adr;
} plus_crap[3] = { { { 0x00, 0x00 }, 0 },
    { { 0x00, 0x00 }, 0 },
    { { 0x00, 0x00 }, 0 } };

and want the following brace/new line arrangement (don't worry about the indenting):

static struct {
    unsigned char streamid[2];
    uint32_t adr;
} plus_crap[3] = {
    { { 0x00, 0x00 }, 0 },
    { { 0x00, 0x00 }, 0 },
    { { 0x00, 0x00 }, 0 }
};

any idea on uncrustify options to get it?

1

There are 1 best solutions below

1
CDanU On

No you won't get that as you are hitting the limits here. We don't play compiler so we only know that you are assigning to a variable, we don't know how it is structured.

The only options that you can play around for this case are:

# Whether to add a newline after the type in an unnamed temporary
# direct-list-initialization.
nl_type_brace_init_lst          = force    # ignore/add/remove/force

# Whether to add a newline after the open brace in an unnamed temporary
# direct-list-initialization.
nl_type_brace_init_lst_open     = force    # ignore/add/remove/force

# Whether to add a newline before the close brace in an unnamed temporary
# direct-list-initialization.
nl_type_brace_init_lst_close    = force    # ignore/add/remove/force

I doubt however that they will help you.