My code is split across multiple .cpp
files, and I’ve just introduced some retained
variables to use the Backup RAM, which is working really well.
However, I have a syntax question - as these are global variables, defined in one C file and used in another, should i use the retained
keyword on the extern
definitions?
E.g.:
application.cpp:
retained bool setupDone = false;
void setup() {
// Interactive setup stuff here...
setupDone = true;
}
cloud_funcs.cpp:
retained extern setupDone; // <--- Is 'retained' neccessary/recommended?
int publishStatus(String command) {
if(setupDone) {
// Publish stuff for cloud interface
}
}
Thanks!
Paul