2 ms·
> * No global or static variables if you can help it (you probably can) I can't imagine doing this on embedded systems.
by janice1999 2y ago
> * No global or static variables if you can help it (you probably can)
I can't imagine doing this on embedded systems.
- naasking 2y agoI think it's better understood as, "global and static state should only be declared by the client". So all of your functions should take pointers and all of your data should preferably be declared as types, and the points of your program that consume your code can declare their lifetime. So if you're inclined to declare 2 global variables, instead define a struct with those two values and your functions take a pointer to that struct, and whatever code calls into yours can then decide whether they want to define that struct as having global scope. It just makes for more modular code.
- lifthrasiir 2y agoThat's what I meant by "some obvious exceptions" :-)