[PATCH] configure: add --without-api-docs option
[notmuch-archives.git] / 29 / e8341f3a61fb4f597f679757d93f98d5cb328d
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 D77514041CF\r
6         for <notmuch@notmuchmail.org>; Mon,  9 Apr 2012 14:31:42 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \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 p27yqgte60DQ for <notmuch@notmuchmail.org>;\r
16         Mon,  9 Apr 2012 14:31:42 -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 D49B84041C4\r
21         for <notmuch@notmuchmail.org>; Mon,  9 Apr 2012 14:31:41 -0700 (PDT)\r
22 Received: by lahc1 with SMTP id c1so3966278lah.26\r
23         for <notmuch@notmuchmail.org>; Mon, 09 Apr 2012 14:31:38 -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:subject:in-reply-to:references:date:message-id:mime-version\r
27         :content-type:x-gm-message-state;\r
28         bh=AY7koQTds8NWhz9uJK02k6P8bSg/aP55lxA8gPkTKe4=;\r
29         b=PfMHwIrWncbgpqnmsXZ9pzSFQevk2TuucYF6lBvbFxcjg4bijeQ6uf3ow9i8/3MBOD\r
30         iKhIGRQ97UqYrts56RqWAPSAzpaHTwSmlw8QthtwpeEiCkRKR0mrOGBL4nLeYjMKBG2S\r
31         q/vtLdVyPq0AHSqqXcQA72OcofHdclLonbOa1JtoyLsvi+qUO7f/k37lDsaJiHCdkbYm\r
32         TFazyXgxFdKqrN869Yiw+3blnH7eBHzKEEr4ORhuU0/ZaLu1JDGpSTprluFirfbT0i8T\r
33         f7de+w6qfdmoty/y0ddw34qUwj4xTQn64lRL5jIOJji3XSRq80NaXVb3eRfxJceGMlwC\r
34         Bujg==\r
35 Received: by 10.152.125.41 with SMTP id mn9mr13092580lab.30.1334007098775;\r
36         Mon, 09 Apr 2012 14:31:38 -0700 (PDT)\r
37 Received: from localhost (dsl-hkibrasgw4-fe50dc00-68.dhcp.inet.fi.\r
38         [80.220.80.68])\r
39         by mx.google.com with ESMTPS id u4sm17074007lad.5.2012.04.09.14.31.36\r
40         (version=SSLv3 cipher=OTHER); Mon, 09 Apr 2012 14:31:37 -0700 (PDT)\r
41 From: Jani Nikula <jani@nikula.org>\r
42 To: Vladimir Marek <Vladimir.Marek@Oracle.COM>,\r
43         Notmuch Mail <notmuch@notmuchmail.org>\r
44 Subject: Re: [PATCH 4/4] Explicitly type void* pointers\r
45 In-Reply-To: <20120409181543.GC10554@pub.czech.sun.com>\r
46 References: <1333966665-10469-1-git-send-email-Vladimir.Marek@oracle.com>\r
47         <1333966665-10469-5-git-send-email-Vladimir.Marek@oracle.com>\r
48         <CAB+hUn_QyMAfC1-Dr23T63ObX=cwuBOzcyCi=61w0MtGRMyt2w@mail.gmail.com>\r
49         <20120409181543.GC10554@pub.czech.sun.com>User-Agent:\r
50         Notmuch/0.12+81~g839a805 (http://notmuchmail.org) Emacs/23.3.1\r
51         (i686-pc-linux-gnu)\r
52 Date: Tue, 10 Apr 2012 00:31:34 +0300\r
53 Message-ID: <87mx6ka8y1.fsf@nikula.org>\r
54 MIME-Version: 1.0\r
55 Content-Type: text/plain; charset=us-ascii\r
56 X-Gm-Message-State:\r
57  ALoCoQnwprzR8WVSMLExIIU3AmRHsiK8Zh3/rUo+S+L15VPsqqP3Qjz2vaOOwAdsYVGbT5VgzRV7\r
58 X-BeenThere: notmuch@notmuchmail.org\r
59 X-Mailman-Version: 2.1.13\r
60 Precedence: list\r
61 List-Id: "Use and development of the notmuch mail system."\r
62         <notmuch.notmuchmail.org>\r
63 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
64         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
65 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
66 List-Post: <mailto:notmuch@notmuchmail.org>\r
67 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
68 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
69         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
70 X-List-Received-Date: Mon, 09 Apr 2012 21:31:43 -0000\r
71 \r
72 Vladimir Marek <Vladimir.Marek@Oracle.COM> writes:\r
73 \r
74 > Hi,\r
75 >\r
76 >> Hi, does notmuch not compile without this? IIRC talloc_steal is a macro\r
77 >> that's supposed to provide type safety (at least with GCC), and I'd be\r
78 >> hesitant about adding the casts. Please look in your talloc.h.\r
79 >\r
80 > It does not compile. It might be that I'm using Sun/Oracle CC instead of\r
81 > gcc. The error looks like this:\r
82 >\r
83 > "lib/database.cc", line 1368: Error: Cannot assign void* to const char*.\r
84 \r
85 In general, that's not a difference in the C++ compilers. You can't\r
86 assign 'void *' to 'T *' in C++.\r
87 \r
88 > When looking into talloc documentation, the definition seems to be:\r
89 >\r
90 > void* talloc_steal ( const void * new_ctx, const void * ptr )\r
91 >\r
92 > http://talloc.samba.org/talloc/doc/html/group__talloc.html#gaccc66139273e727183fb5bdda11ef82c\r
93 >\r
94 >\r
95 > When looking into talloc.h, it says:\r
96 >\r
97 > /* try to make talloc_set_destructor() and talloc_steal() type safe,\r
98 >    if we have a recent gcc */\r
99 \r
100 It just so happens that the trick for type safety fixes the problem for\r
101 recent GCC by having an explicit cast.\r
102 \r
103 > So, maybe the way to satisfy everyone would be:\r
104 >\r
105 > notmuch_message_t *tmp_message = message;\r
106 > talloc_steal(notmuch, tmp_message);\r
107 > return(tmp_message);\r
108 >\r
109 > Or alternatively,\r
110 >\r
111 > #if (__GNUC__ >= 3)\r
112 >        return talloc_steal (notmuch, message);\r
113 > #else\r
114 >        return (notmuch_message_t*) talloc_steal (notmuch, message);\r
115 > #fi\r
116 >\r
117 >\r
118 > Of course I'm happy either way :)\r
119 \r
120 I'm throwing in a third alternative below. Does it work for you? I think\r
121 it's both prettier and uglier than the above at the same time! ;)\r
122 \r
123 A middle ground would be to change the callers to use\r
124 "notmuch_talloc_steal", and just #define notmuch_talloc_steal\r
125 talloc_steal if __GNUC__ >= 3.\r
126 \r
127 One could argue upstream talloc should have this, but OTOH it's a C\r
128 library.\r
129 \r
130 BR,\r
131 Jani.\r
132 \r
133 \r
134 diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h\r
135 index ea836f7..83b46e8 100644\r
136 --- a/lib/notmuch-private.h\r
137 +++ b/lib/notmuch-private.h\r
138 @@ -499,4 +499,22 @@ _notmuch_filenames_create (const void *ctx,\r
139  \r
140  NOTMUCH_END_DECLS\r
141  \r
142 +#ifdef __cplusplus\r
143 +/* Implicit typecast from 'void *' to 'T *' is okay in C, but not in\r
144 + * C++. In talloc_steal, an explicit cast is provided for type safety\r
145 + * in some GCC versions. Otherwise, a cast is required. Provide a\r
146 + * template function for this to maintain type safety, and redefine\r
147 + * talloc_steal to use it.\r
148 + */\r
149 +#if !(__GNUC__ >= 3)\r
150 +template <class T>\r
151 +T *notmuch_talloc_steal(const void *new_ctx, const T *ptr)\r
152 +{\r
153 +    return static_cast<T*>(talloc_steal(new_ctx, ptr));\r
154 +}\r
155 +#undef talloc_steal\r
156 +#define talloc_steal notmuch_talloc_steal\r
157 +#endif\r
158 +#endif\r
159 +\r
160  #endif\r