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
[qt] Rename Component::requires to avoid clash with C++20 #414
base: master
Are you sure you want to change the base?
Conversation
qt/component.cpp
Outdated
| } | ||
| #endif | ||
|
|
||
| QList<Relation> Component::requiresComponents() const |
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.
IMO could be requiredComponents
| @@ -364,7 +364,14 @@ QList<Relation> Component::recommends() const | |||
| return res; | |||
| } | |||
|
|
|||
| #if __cplusplus < 202002L | |||
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.
Maybe add a #warning in an #endif so that if AppStreamQt is built with C++20, it will be ABI incompatible?
|
Thank you for the patch! I do think |
That kind of change seems somewhat, well, hostile to your existing userbase... |
Yeah, it really sucks, it basically forces an ABI break - and some better-name searching (if |
|
You can use asm to create a symbol alias to continue exporting a symbol with the old name, so there's no ABI break. |
|
https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gcc/Common-Function-Attributes.html#Common-Function-Attributes |
The |
Wouldn't |
That's probably what I would go with... It's called "requires" because that's what the tag name is in metadata and it jives well with the existing replaces/extends/recommends/supports - to be consistent those would also need to be named "recommendations", "replacement_for", "supporting" etc, which is a bit weird. |
In C++20 requires is a reserved keyword This results in a build failure when a C++20 project includes component.h To avoid the issue the method gets a new name (requirements). The old method is marked as deprecated and hidden when building in C++20 mode Fixes ximion#342
|
Renamed it to requirements |
I'm not sure I follow. That site says "The alias attribute causes the declaration to be emitted as an alias for another symbol, which must have been previously declared with the same type". So in order to create an alias for it I have to declare it, but I can't, because the name is a keyword. Or am I misunderstanding something? |
|
You can define it in a translation unit compiled with C++17 (or earlier) where it's not a keyword, and make it an alias to the new name. Or just make it call the new function. You can also declare it as an |
The "requires" word became reserved in recent C++ standards, so we can no longer use it here and it will be removed in AppStream 1.0. We provide the replacement "requirements" function now, to simplify future migrations. CC: #414
In C++20 requires is a reserved keyword
This results in a build failure when a C++20 project includes component.h
To avoid the issue the method gets a new name (requiresComponents). The old method is marked as deprecated and hidden when building in C++20 mode
Fixes #342