I'm in the last stages of establishing a typedef for
data returned from headerGetEntry() et al methods.

Since the data is typed, a union is being used:
union hRET_s {
   void * ptr;
   const char ** argv;
   const char * str;
   uint_64 * ui64p;
   uint_32 * ui32p;
   uint_16 * ui16p;
   uint_8 * ui8p;
   int_64 * i64p;
   int_32 * i32p;
   int_16 * i16p;
   int_8 * i8p;
};
typedef union hRET_s rpmTagData;

Since the current API uses "const void *", there is a need to
convert the void * to a union pointer at the moment. I'll fight the
   You changed rpmlib's API!
issues after all the work is actually done.

Well I'm baffled by how to achieve the cast. Everything I've tried with casts fails to compile.

This hackery with an extra level of indirection manages to change
the pointer type, but is perhaps overkill:

int headerAddEntry(Header h, int_32 tag, rpmTagType type,
               const void * p, rpmTagCount c)
       /[EMAIL PROTECTED] h @*/
{
   rpmTagData *q = (void *)&p;
   return (h2hv(h)->hdradd) (h, tag, type, *q, c);
}

So how does one achieve casting from void * to a union?

Inquiring minds want to know ...

73 de Jeff

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to