Well, the only way I see is unpleasant:
#define LISTA_INIT_EMPTY { .next = (&my_list), .prev = (&my_list) }
I do not like it at all, since it only works if your variable is called my_list . And there is nothing good, since this does not exist in C.
Why not use NULL instead of pointing to "this"? If this is not satisfactory, saving a parameterized macro is probably the best.
EDIT: (thanks R comment below, I finally understood the need):
Since there is no βthisβ and only enter the variable name once, I suggest using a macro like this:
#define CREATE_EMPTY_LISTA(name) struct lista name = { .next=&name, .prev=&name }
And later in the code:
CREATE_EMPTY_LISTA(my_list);
source share