openSUSE / libsolv

Library for solving packages and reading repositories
http://en.opensuse.org/openSUSE:Libzypp_satsolver
Other
509 stars 151 forks source link

libzypp and code using it can't be built with a C++20 compiler #556

Closed berolinux closed 3 months ago

berolinux commented 3 months ago

libzypp uses requires as variable and method names - but in C++20 and higher, requires is a keyword. https://en.cppreference.com/w/cpp/language/requires

C++20 (and higher) compilers barf on https://github.com/openSUSE/libzypp/blob/master/zypp/sat/SolvAttr.h#L67 https://github.com/openSUSE/libzypp/blob/master/zypp/sat/Solvable.h#L225 https://github.com/openSUSE/libzypp/blob/master/zypp/sat/Solvable.h#L240 https://github.com/openSUSE/libzypp/blob/master/zypp/sat/SolvableType.h#L106

and the headers from libsolv, which suffer the same problem.

A quick (but dirty) "fix" without changing the API would be adding

#define requires rpmRequires

before the problematic definitions, and

#undef requires

after.

mlschroe commented 3 months ago

You can already define LIBSOLV_SOLVABLE_PREPEND_DEP to rename the dependencies, e.g. requires to dep_requires.