Old post, but may be useful
You can try something like this in C, C++ is very similar
Typedef struct {
char *name;
int data;
struct MyList *next;
} MyList;
Mylist junk[] = {
{"One" ,1, &junk[1]},
{"Two", 2, &junk[2]},
{"Three",3, (MyList *) 0}
};
MyList *head = &junk[0];
is a pointer to the head of the list.....
These lists are very useful and common in small embedded interpereters. Lisp and Forth come immediately to mind. and many other places.
Look at stackflow discussion self referential struct definition?
Doing list surgery may be an issue since the compiled list may live in non volatile memory - though in more modern CPU this is probably in flash.
As you can see in the above post there's nothing inherently bad in lists, they're just tricky to use and methods to use them are not taught as rigorously as in the past.
The awful syntax you often try (e.g. ) is simply an artifact of C/C++ languages which was not designed to enable easy representation of lists of pointers in code.
You can also try something of the form
MyList a = {"A",(MyList *) 0};
MyList b = {"B",&a);
Another common pattern is to do the initialization programatically
MyList *m = NewMyList("A");
MyListAdd(m,"B");
You find a lot of this in Java where there are good container class libraries. Downside is that your startup may take a few extra milliseconds.
Another common usage is to use relative links .... in the array example above, replace the link by sizeof(MyList). This makes for easier programming plus the list becomes relocatable
and can be copied (eg from FLASH to RAM and back) using standard memcpy type operations.
have fun
Chris