STARTUP() called multiple times

In my code I call the startup macro a few times for a few different reasons. I have two questions about this:

First, is there some limit of calls to the startup macro? Or can it be called as many times as necessary? E.g. which of the following is better:

STARTUP(System.enableFeature(FEATURE_RETAINED_MEMORY));
STARTUP(System.enableFeature(FEATURE_RESET_INFO));

OR

void startupMacro() {
     System.enableFeature(FEATURE_RETAINED_MEMORY);
     System.enableFeature(FEATURE_RESET_INFO);
}
STARTUP(startupMacro());

Second, are there any issues with calling the same startup function multiple times? E.g. if I use a library that calls a startup function, like STARTUP(System.enableFeature(FEATURE_RETAINED_MEMORY)); and then I call that same startup function again elsewhere, are any issues created?

Both of the above seem to be ok, but want to get an authoritative answer on this.

1 Like

I use function STARTUP() three times separately and works great.
And I would like to know which is the correct way to use the function?
Are there any restrictions or is resolved during the compiling?

@hwestbrook, if I recall, @mdma recommended doing a single STARTUP() call with whatever you need in a single function (as you showed). Mind you, I have not heard of any problems having multiple STARTUP() lines. :wink:

1 Like

@peekay123,

I saw that as well, but I would like to know why, if @mdma has a second to explain. For what I am doing, it is a lot nicer to call the STARTUP macro multiple times (e.g. have two libraries I’ve created be able to call it independently) so I am curious what the tradeoffs would be. I’ve looked through github.com/spark/firmware, but I can’t quite figure out how it works.