[PATCH 4/4] Explicitly type void* pointers
Vladimir Marek
Vladimir.Marek at Oracle.COM
Mon Apr 9 11:15:43 PDT 2012
Hi,
> Hi, does notmuch not compile without this? IIRC talloc_steal is a macro
> that's supposed to provide type safety (at least with GCC), and I'd be
> hesitant about adding the casts. Please look in your talloc.h.
It does not compile. It might be that I'm using Sun/Oracle CC instead of
gcc. The error looks like this:
"lib/database.cc", line 1368: Error: Cannot assign void* to const char*.
When looking into talloc documentation, the definition seems to be:
void* talloc_steal ( const void * new_ctx, const void * ptr )
http://talloc.samba.org/talloc/doc/html/group__talloc.html#gaccc66139273e727183fb5bdda11ef82c
When looking into talloc.h, it says:
/* try to make talloc_set_destructor() and talloc_steal() type safe,
if we have a recent gcc */
So, maybe the way to satisfy everyone would be:
notmuch_message_t *tmp_message = message;
talloc_steal(notmuch, tmp_message);
return(tmp_message);
Or alternatively,
#if (__GNUC__ >= 3)
return talloc_steal (notmuch, message);
#else
return (notmuch_message_t*) talloc_steal (notmuch, message);
#fi
Of course I'm happy either way :)
Thank you
--
Vlad
More information about the notmuch
mailing list