appstream icon indicating copy to clipboard operation
appstream copied to clipboard

Build error in C++20 project

Open nicolasfella opened this issue 2 years ago • 2 comments

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;

nicolasfella avatar Aug 06 '21 10:08 nicolasfella

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 avatar Aug 10 '21 14:08 ximion

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 avatar Jan 06 '22 20:01 nicolasfella

This is actually resolved now, with an API break in the 1.0 development branch.

ximion avatar Apr 11 '23 22:04 ximion