1 Return-Path: <jani@nikula.org>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 84511431FAF
\r
6 for <notmuch@notmuchmail.org>; Thu, 12 Apr 2012 13:57:47 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id EgmJRd8cC-IW for <notmuch@notmuchmail.org>;
\r
16 Thu, 12 Apr 2012 13:57:47 -0700 (PDT)
\r
17 Received: from mail-lpp01m010-f53.google.com (mail-lpp01m010-f53.google.com
\r
18 [209.85.215.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id AA8AB431FAE
\r
21 for <notmuch@notmuchmail.org>; Thu, 12 Apr 2012 13:57:46 -0700 (PDT)
\r
22 Received: by lahc1 with SMTP id c1so1939174lah.26
\r
23 for <notmuch@notmuchmail.org>; Thu, 12 Apr 2012 13:57:43 -0700 (PDT)
\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
25 d=google.com; s=20120113;
\r
26 h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state;
\r
27 bh=o/2zKP+UOcE6THnHoJHxtPJf/VI5kIe9FPDmzRHdkpQ=;
\r
28 b=bNkmI+p57BRwBnvZNsr4upWafK6KPhrYzy++nSiMEiB94RbwmRzJ2nhRlFX297Mvpe
\r
29 ckLRH59JNBsdLj2lpI5/8G7ytmYyO/0EoHgXaGacT7afdOC4UlsZmEvWNFPAo8m0EEYi
\r
30 OfIeR8deYgQLTLS+N9+DdkshVysHQ/TRZX3jyiDSjqW9M88mqxdbDWoTYDdU4QShZZtr
\r
31 hOcOre8Wc/MfhfGzd5B8+44IMUB4fTSlRRzCRa9qA6iBQXOwC5y6h/pv2KrgvPMff5Nh
\r
32 c+YBz9Fti2nTjgiUd60YHdxKctplvMDRRjtYQfwKPkO17M3uQ83SuqM0/Z0BsIs6yTrR
\r
34 Received: by 10.112.29.166 with SMTP id l6mr1699501lbh.78.1334264263574;
\r
35 Thu, 12 Apr 2012 13:57:43 -0700 (PDT)
\r
36 Received: from localhost (dsl-hkibrasgw4-fe50dc00-68.dhcp.inet.fi.
\r
38 by mx.google.com with ESMTPS id u4sm7291312lad.5.2012.04.12.13.57.41
\r
39 (version=SSLv3 cipher=OTHER); Thu, 12 Apr 2012 13:57:42 -0700 (PDT)
\r
40 From: Jani Nikula <jani@nikula.org>
\r
41 To: notmuch@notmuchmail.org
\r
42 Subject: [PATCH] lib: work around talloc_steal usage from C++ code
\r
43 Date: Thu, 12 Apr 2012 23:57:39 +0300
\r
44 Message-Id: <1334264259-17632-1-git-send-email-jani@nikula.org>
\r
45 X-Mailer: git-send-email 1.7.5.4
\r
47 ALoCoQl5NB2XQPkT53ya621KRRQDH/VE8iYbiR1gs9nYh0/5b1DzOmnXcZqMLSozxingnK4yOeLK
\r
48 X-BeenThere: notmuch@notmuchmail.org
\r
49 X-Mailman-Version: 2.1.13
\r
51 List-Id: "Use and development of the notmuch mail system."
\r
52 <notmuch.notmuchmail.org>
\r
53 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
54 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
55 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
56 List-Post: <mailto:notmuch@notmuchmail.org>
\r
57 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
58 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
59 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
60 X-List-Received-Date: Thu, 12 Apr 2012 20:57:47 -0000
\r
62 Implicit typecast from 'void *' to 'T *' is okay in C, but not in
\r
63 C++. In talloc_steal, an explicit cast is provided for type safety in
\r
64 some GCC versions. Otherwise, a cast is required. Provide a template
\r
65 function for this to maintain type safety, and redefine talloc_steal
\r
68 The template must be outside the extern "C" block (NOTMUCH_BEGIN_DECLS
\r
69 and NOTMUCH_END_DECLS), but keep it within the GCC visibility #pragma.
\r
71 No functional changes, apart from making the library build with
\r
72 compilers other than recent GCC.
\r
74 Signed-off-by: Jani Nikula <jani@nikula.org>
\r
78 For background, see discussion starting at
\r
79 id:"1333966665-10469-5-git-send-email-Vladimir.Marek@oracle.com"
\r
81 Vladimir, please test this. Thanks.
\r
83 lib/notmuch-private.h | 22 ++++++++++++++++++++--
\r
84 1 files changed, 20 insertions(+), 2 deletions(-)
\r
86 diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
\r
87 index ea836f7..3886e0c 100644
\r
88 --- a/lib/notmuch-private.h
\r
89 +++ b/lib/notmuch-private.h
\r
90 @@ -495,8 +495,26 @@ notmuch_filenames_t *
\r
91 _notmuch_filenames_create (const void *ctx,
\r
92 notmuch_string_list_t *list);
\r
94 -#pragma GCC visibility pop
\r
99 +/* Implicit typecast from 'void *' to 'T *' is okay in C, but not in
\r
100 + * C++. In talloc_steal, an explicit cast is provided for type safety
\r
101 + * in some GCC versions. Otherwise, a cast is required. Provide a
\r
102 + * template function for this to maintain type safety, and redefine
\r
103 + * talloc_steal to use it.
\r
105 +#if !(__GNUC__ >= 3)
\r
106 +template <class T> T *
\r
107 +_notmuch_talloc_steal (const void *new_ctx, const T *ptr)
\r
109 + return static_cast<T *> (talloc_steal (new_ctx, ptr));
\r
111 +#undef talloc_steal
\r
112 +#define talloc_steal _notmuch_talloc_steal
\r
116 +#pragma GCC visibility pop
\r