-
Notifications
You must be signed in to change notification settings - Fork 7.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Clarification] Does std::chrono::milliseconds use 45 bits or does it wrap around at 32 bits? (IDFGH-1605) #3860
Comments
The short answer is that The long answer is that the question mentions a number of timekeeping features, but they're not all related to each other:
For future reference, as this is a question rather than an bug report/feature request/etc for ESP-IDF then the best place to ask it would be the https://esp32.com forums. |
Thank you very much for the detailed response (and your patience with my question here). I've already started the process of becoming Arduino-free and am trying to disentangle myself from that system and API as much as I can. There are obviously some misunderstandings I still have. In the future I'll take these sorts of questions to the forums. Thanks again for all the details. |
@ssilverman Glad that the answer was helpful. Good luck with your continued journey into embedded C++ land. :) |
It's just that all these Arduino-related classes are so handy: AsyncUDP, ESPAsyncWebServer, IPAddress, Print, WiFi, FastLED, Preferences, etc. All those rely on some Arduino something or other. That's why I'm having a bumpy time moving completely to ESP-IDF. |
ssilverman, I have experimented with ESP-IDF. It uses modules. There is a usable "Arduino" module which you can plug into your project. This allows libc compilation whilst still using your favourite Arduino bits. Kind regards, and good luck with your endevours. |
The C++ spec says that the
std::chrono::milliseconds
type should be at least 45 bits (https://en.cppreference.com/w/cpp/chrono/duration). Since the HAL (esp32-hal.h
) definesmillis()
as returningunsigned long
, and since that's only defined to be "at least 32 bits" in the C++ spec (https://en.cppreference.com/w/cpp/language/types), I just want to confirm that retrieving the milliseconds using thechrono
library doesn't wrap around at 32 bits, and it is a true 64-bit value.Example code:
Side question: Where do I find where the C++ core libraries use the ESP32 HAL to implement everything? For example, mutexes or yield() or the chrono library. I'd like to read the source so I can confirm these things myself.
The text was updated successfully, but these errors were encountered: