-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
We have many places where it would be really nice to add an entry to a shared array, from any file.
Think auto_init, shell_commands, device driver parameters, network interfaces, sensors, libc initializers, ...
I really appreciate that we haven't chosen to go libc's route of using the linker to sort these things out.
Still, I think that the current pile of hacks will get harder to maintain the more features RIOT gets.
I'm trying to come up with a nice way to be able to add entries to a global, shared array (per type).
I think all of the above can efficiently be modeled using const arrays of structs.
Something like:
in sys/random/sc_random.c:
SHELL_COMMAND { "random_init", function, ... }
in sys/gnrc/blah.c:
SHELL_COMMAND { "gnrc_print_blah", function, ... }
ends up as, e.g., bin/include/shell_commands_array.h:
shell_command_t shell_commands[] = {
{ "random_init", function, ... },
{ "gnrc_print_blah", function, ... },
}
IMHO, if we do this right, we can reuse it for all of the above "lists".
But:
- C can't do it by itself
- generated code sucks
- ...
Opinions?