RPM Community Forums

Mailing List Message of <rpm-devel>

Re: [CVS] RPM: rpm/lib/ rpm4compat.h

From: Bernhard Rosenkränzer <bero@arklinux.ch>
Date: Fri 18 Jul 2008 - 19:30:04 CEST
Message-Id: <200807181930.05126.bero@arklinux.ch>
On Friday 18 July 2008 17.12:31 Jeff Johnson wrote:
> - rpm4compat: fix: rpmdsSingle() is a C, not a C++, routine.

That was right before - the purpose of rpmdsSingle() in rpm4compat.h 
(intentionally in #ifdef __cplusplus) is a workaround for a difference 
between C and C++:

In rpm4, rpmdsSingle was:

rpmds rpmdsSingle(rpmTag tagN, const char *N, const char *EVR, int_32 Flags)

in rpm5, it is:

rpmds rpmdsSingle(rpmTag tagN, const char *N, const char *EVR, evrFlags Flags)

In terms of C, those provide an identical API, in terms of C++, it means old 
code doesn't compile unless you add a cast to evrFlags for the last 
parameter.

The purpose of the inline function in rpm4compat.h is to provide a function 
with the rpm4 conventions that just casts the last parameter and then calls 
the new function (in C++, you can have 2 functions with the same name as long 
as they take different parameters).

The apt hang was caused by the missing #include <rpm/rpmds.h> I added earlier: 
Since the inline function didn't know about the "real" rpmdsSingle (because 
of the missing include), it just kept calling itself (a cast from an enum 
(such as evrFlags) to an int is automatic, while a cast from an enum to int 
is not).

If the function knows about the real one (which it does after #include 
<rpm/rpmds.h>), it sees that the real one is a better match for what it is 
calling, and therefore calls that as opposed to itself -- which is the 
intended behavior.
Received on Fri Jul 18 19:30:17 2008
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.