-
Notifications
You must be signed in to change notification settings - Fork 3k
Deprecate MBED_STATIC_ASSERT and MBED_STRUCT_STATIC_ASSERT for built-in keyword #13002
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
Conversation
e152329 to
94ac552
Compare
94ac552 to
4c2f059
Compare
|
I want to mention that while I marked the MBED_STRUCT_STATIC_ASSERT as deprecated inside the doxygen comments, I could not figure out a way to accomplish this. I tried:
None were successful. I could have easily caused problems with typos and the like, but in any case, if this is something useful and possible, I'll have to be shown the right way to do it. Finally, fun fact: you can write "struct" in the code comments and it will pass the doxygen spell checker, but you cannot do that with "structs". |
|
@pea-pod, thank you for your changes. |
platform/mbed_assert.h
Outdated
| * @endcode | ||
| */ | ||
| #if defined(__cplusplus) && (__cplusplus >= 201103L || __cpp_static_assert >= 200410L) | ||
| #if defined(__cplusplus) && __cplusplus >= 201402L |
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.
The C++ and C version tests aren't required. Code base is permitted to just assume C++14 and C11.
Plenty of C++14 assumptions in-tree already. Although maybe not C11. But GNU C, ARMC6 and IAR are all set to C11.
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.
Ok. I will further simplify this.
There is a whitelist somewhere in |
I understand. I did put the Doxygen tag in there for the |
4c2f059 to
c51d320
Compare
|
The next question is does the macro even need to exist at all now? Once you've hit C++14/C11, you can assume it's part of the language. No need for the compiler fudging at all. Obviously there could be some need for fudging for misbehaving compilers (as for anything), but I've already been using So maybe even mark the base macro deprecated, and strip from codebase? Thoughts @0xc0170 / @evedon / @bulislaw ? |
|
I guess (Since C99, C has chosen not to add new non-reserved keywords, so the tokens are all |
c51d320 to
b1471fe
Compare
|
Ok. I just updated it to add deprecation messages to both. If this is accepted, I will change the PR title to "Deprecate MBED_STATIC_ASSERT and MBED_STRUCT_STATIC_ASSERT" and clean up the rest of the PR body as necessary. |
platform/mbed_assert.h
Outdated
| * | ||
| * @deprecated This feature is now no longer necessary with the minimum | ||
| * supported language versions. It will be removed in a forthcoming release. | ||
| * Use `static_assert` for C++. For C, use either `_Static_assert` or |
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.
I'd rephrase this to just
Use `static_assert` instead. For C this is provided by `<assert.h>`, and for C++ it is a built-in keyword.
We'd never expect anyone to use _Bool, so no point telling them to use _Static_assert.
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.
Done.
b1471fe to
5fb87eb
Compare
|
@kjbracey-arm is this ready to put through CI? |
|
CI started |
Test run: SUCCESSSummary: 6 of 6 test jobs passed |
|
It's just come to my attention that ARM Compiler 6 may be missing its This is still fine for me, but I think a follow-up patch that adds would be in order. |
Summary of changes
Deprecates (in doxygen only)
MBED_STATIC_ASSERTandMBED_STRUCT_STATIC_ASSERTmacros as these uses are now provided with the built-instatic_assert(or for C without<assert.h>:_Static_assert).Cuts down the number of
MBED_STATIC_ASSERTandMBED_STRUCT_STATIC_ASSERTmacro definition#ifcases to just C++ or not C++.If
static_assertis not recognized by the compiler, it implies it is before either C11 or C++11. I do not consider this a breaking change as C11 and C++14 are now the minimum supported language versions.These changes also clean up some of the code documentation as well.
Impact of changes
This should only go in v6.0.0, so no issues assuming at least C11 or C++14 are used.
Migration actions required
Since the
MBED_STATIC_ASSERTandMBED_STRUCT_STATIC_ASSERTmacros are deprecated, users should usestatic_assertgoing forward as these could eventually be removed.Documentation
Documentation updated in the modified file.
Pull request type
Test results
Reviewers