X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Fnotmuch-private.h;h=3886e0ca0c86475e242ca6a7adf61b6b91c2d74e;hp=ea836f721291c3d7d84bfb9edb3f70b3ea717155;hb=de0557477d908be26615e8fda9f5eb62bed68b65;hpb=596a2076dcc1ebec2dc217f6d967397ef125aac4 diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h index ea836f72..3886e0ca 100644 --- a/lib/notmuch-private.h +++ b/lib/notmuch-private.h @@ -495,8 +495,26 @@ notmuch_filenames_t * _notmuch_filenames_create (const void *ctx, notmuch_string_list_t *list); -#pragma GCC visibility pop - NOTMUCH_END_DECLS +#ifdef __cplusplus +/* Implicit typecast from 'void *' to 'T *' is okay in C, but not in + * C++. In talloc_steal, an explicit cast is provided for type safety + * in some GCC versions. Otherwise, a cast is required. Provide a + * template function for this to maintain type safety, and redefine + * talloc_steal to use it. + */ +#if !(__GNUC__ >= 3) +template T * +_notmuch_talloc_steal (const void *new_ctx, const T *ptr) +{ + return static_cast (talloc_steal (new_ctx, ptr)); +} +#undef talloc_steal +#define talloc_steal _notmuch_talloc_steal +#endif +#endif + +#pragma GCC visibility pop + #endif