4 ms·
You can sort the array during program initialization, if you care about the order.
by loeg 7y ago
You can sort the array during program initialization, if you care about the order.
- monocasa 7y agoIt's probably already in link order. If you have to know the names of the symbols in code to be able to sort them, it sort of defeats the purpose of the scheme in the first place.
- loeg 7y agoYou might want to sort them by some other criteria. For example, the FreeBSD kernel's use of this construct embeds a well-defined priority[1], and the array is sorted by this priority value at boot time.[2] [1]: https://github.com/freebsd/freebsd/blob/master/sys/sys/kernel.h#L76-L175 https://github.com/freebsd/freebsd/blob/master/sys/sys/kerne... [2]: https://github.com/freebsd/freebsd/blob/master/sys/kern/init_main.c#L217-L265 https://github.com/freebsd/freebsd/blob/master/sys/kern/init...