Skip to content
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

Build error in C++20 project #342

Open
nicolasfella opened this issue Aug 6, 2021 · 2 comments · May be fixed by #414
Open

Build error in C++20 project #342

nicolasfella opened this issue Aug 6, 2021 · 2 comments · May be fixed by #414

Comments

@nicolasfella
Copy link
Contributor

qt/component.h has a function named 'requires'. When including this header in a project that is building with C++20 this will result in a compile error since requires is a reserved keyword in C++20

In file included from /usr/include/AppStreamQt/pool.h:28,
                 from /home/nico/kde/src/plasma-workspace/applets/kicker/plugin/actionlist.cpp:45:
/usr/include/AppStreamQt/component.h:195:36: error: expected unqualified-id before 'requires'
  195 |         QList<AppStream::Relation> requires() const;
@ximion
Copy link
Owner

ximion commented Aug 10, 2021

Hmm... I am not sure how to resolve this without an API break. Is there any best practice on how to deal with these kinds of issues?

@ximion ximion added this to the AppStream 1.0 milestone Sep 9, 2021
@nicolasfella
Copy link
Contributor Author

good question. I'd say we introduce a new alternative name, mark the old one as deprecated and ifdef the old one out when building against C++20. People upgrading to C++20 are going to have a breakage, but that way we'd avoid/postpone the breakage for people with older C++

nicolasfella added a commit to nicolasfella/appstream that referenced this issue Jun 23, 2022
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 ximion#342
nicolasfella added a commit to nicolasfella/appstream that referenced this issue Nov 12, 2022
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants