I had some code that was working just fine measuring elapsed time using C++ elapsedMillis objects that were defined as static objects at file level scope (ie outside any functions). To improve maintainability I moved some of the static elapsed time objects into the functions they were associated with. And they no longer worked -- meaning they didn't measure elapsed time right. I'm suspecting that it's an issue with the constructor table that the tool chain builds. "Normally" when doing host based development the calling of constructors and destructors for C++ is handled automatically. I understand that it's trickier with embedded code. I think the constructors are not being called for objects inside functions.
My "solution" is to just not use C++ static objects inside functions. Just wanted to warn other people about this issue. I looked and couldn't find another post about this problem. I doubt it's platform-specific but I'm developing on Windows using the recent 1.16 release with Arduino 1.0.5.
My "solution" is to just not use C++ static objects inside functions. Just wanted to warn other people about this issue. I looked and couldn't find another post about this problem. I doubt it's platform-specific but I'm developing on Windows using the recent 1.16 release with Arduino 1.0.5.