-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
constexpr helpers to identify core version #5269
Conversation
cores/esp8266/core_esp8266_version.h
Outdated
|
||
#define CORE_ESP8266_MAJOR (2) | ||
#define CORE_ESP8266_MINOR (4) | ||
#define CORE_ESP8266_REVISION (2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's partial overlap between these and the ones in core_version.h.
Can defines in core_version.h be written using these new ones?
I really need to look at this closer, but the one thing I see is that as-defined, development/RC versions will have a greater numeric value than the release version. |
I fully agree with saying that we should have 2.4.1 < 2.4.2 < 2.5.0rc1 < 2.5.0rc2 < 2.5.0.
|
Some comments:
Quick untested example put together on cpp.sh:
I said not necessarily useful, because this evaluates at compile time, not at preprocessor time, so you can't use it to conditionally compile code. I mention it only to raise awareness and to keep it in mind when looking for ways to (slightly) reduce bin size.
|
Using
edit: numeric version is not added to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's like magic. I hope it never breaks, because it'll take Stroustrop himself to fix it. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty good: constexpr is certainly used as I explained, and the logic is reduced in the assembly to reading a const value at compile time (I.e.: a good example of no-overhead programing).
However, and I mention this just to have it explicit somewhere, the user can't do conditional compile of code in the same way as with preprocessor macros. It should be possible to conditionally compile code using this in conjunction with SFINAE, but usage becomes more complex. We can explore that later, though.
Some comments about style:
- instead of having a bunch of functions with prefix "esp8266", it would be better to remove the prefix and put the functions in namespace "esp8266".
- generic functions, such as the constexpr atoi algorithm, should be factored out for possible reuse. They could be put in a subnamespace within esp8266, e.g. const_str or conststrlib or whatever. I'll leave that decision to @d-a-v :)
No description provided.