From owner-freebsd-current@FreeBSD.ORG Tue Nov 12 18:11:35 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B9A081A6 for ; Tue, 12 Nov 2013 18:11:35 +0000 (UTC) Received: from mail-qa0-x22a.google.com (mail-qa0-x22a.google.com [IPv6:2607:f8b0:400d:c00::22a]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 78C922A4F for ; Tue, 12 Nov 2013 18:11:35 +0000 (UTC) Received: by mail-qa0-f42.google.com with SMTP id ii20so3106372qab.1 for ; Tue, 12 Nov 2013 10:11:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eitanadler.com; s=0xdeadbeef; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=V0bZC9ZWr/xnIEPQpWbrBHzUkYJ0CeMbo0xTIQN5VUQ=; b=IqqjwkxIVJKI4iCe4Wx8RkTxEHtNCmZzf+MeWuOVaCU+ZSCKUupvEjg8RAxjZJ8PBV 41NWdKPbcQX5L7K/RKavrDsxu1imAFn7IhQ/OLYrYGbZGiZkdcW8HlukvkK15TEdX3qO eSYeoo2OYxZRxRW1nCHahUjtseILaVjVN9HWA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=V0bZC9ZWr/xnIEPQpWbrBHzUkYJ0CeMbo0xTIQN5VUQ=; b=YTGVTYiCTUWBG066KR+9P9n97PYvOef6gF3O8E6XTC7/dmh+f09lwwaOxog+auTWvy B2eSaRVasT72JPB/RqyYQxS/Abn0XLMi4WOgU7OQ3AQ5JniV267udKr/IZx0Z50qvhOa HWQsQHdOmrzUGEzRqAS3ZxgZ8GKTaTN4PsYnKsbOhAY3066A1mpaycpIH1R/TGS9zegO 9S4Rt8zPZdR1as7xHUGO2C2EyBHpYtkhzT0eTEG8e3Vf8p8hPf7LmI49RJ6akL6cxFui xawBCbRVwsfiFTyHOlIoDupIQnCThlrxhhlIcMGg6YGzysG3/80AECIBNvgZ/kSjg2MI 1SRA== X-Gm-Message-State: ALoCoQlqlUOsMRA8FUT8vbGGjBcrJF5I9xDZj2K8kRo4QNLOfTrnV0442U94JASncs8735MQYW3g X-Received: by 10.224.69.132 with SMTP id z4mr60371537qai.78.1384279894590; Tue, 12 Nov 2013 10:11:34 -0800 (PST) MIME-Version: 1.0 Received: by 10.96.63.101 with HTTP; Tue, 12 Nov 2013 10:11:04 -0800 (PST) In-Reply-To: <20131112165422.GA2939@troutmask.apl.washington.edu> References: <20131112163219.GA2834@troutmask.apl.washington.edu> <77CB2B92-216A-4C80-B033-7E582B5F0DFC@FreeBSD.org> <20131112165422.GA2939@troutmask.apl.washington.edu> From: Eitan Adler Date: Tue, 12 Nov 2013 13:11:04 -0500 Message-ID: Subject: Re: Are clang++ and libc++ compatible? To: Steve Kargl Content-Type: text/plain; charset=UTF-8 Cc: freebsd-current Current , David Chisnall X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Nov 2013 18:11:35 -0000 On Tue, Nov 12, 2013 at 11:54 AM, Steve Kargl wrote: > On Tue, Nov 12, 2013 at 04:38:17PM +0000, David Chisnall wrote: >> On 12 Nov 2013, at 16:32, Steve Kargl wrote: >> >>> Trying to build news/pan with clang++ dies with >>> >>> gmake[3]: Entering directory `/usr/ports/news/pan/work/pan-0.139/pan/general' >>> CXX file-util.o >>> In file included from file-util.cc:38: >>> In file included from ./log.h:26: >>> /usr/include/c++/v1/deque:907:49: error: invalid application of 'sizeof' to an >>> incomplete type 'value_type' (aka 'pan::Log::Entry') >>> static const difference_type __block_size = sizeof(value_type) < 256 ? 4... >>> >>> Anyone know how to fix either clang++ or libc++? >> >> The error here does not appear to be in clang or libc++, but in the >> use by the thing that you are compiling. >> This is saying that you have tried to create a std::dequeu, >> but pan::Log::Entry is a forward declaration and so the template >> instantiation fails. >> The fix is to move the definition of pan::Log::Entry such that it >> is visible at the time of its use. >> > > I don't know C++, but it is at all like C, then the header files > are normally placed at the top of a file before one's code. In > this case, the code in news/pan/work/pan-0.139/pan/general/log.h > looks like (where I've striped comment to keep it short) > > #ifndef __Log_h__ > #define __Log_h__ > > #include > #include > #include > #include > > namespace pan > { > class Log > { > public: > enum Severity { > PAN_SEVERITY_INFO = 1, > PAN_SEVERITY_ERROR = 2, > PAN_SEVERITY_URGENT = (1<<10) > }; > > struct Entry { > time_t date; > Severity severity; > std::deque messages; > std::string message; > bool is_child; > Entry() : is_child(false) { } > }; > > void add_entry(Entry& e, std::deque& list); > > > Are you saying that I need to move '#include ' to > the location above the 'void add_entry(...)' line? The problem here is that the code is trying to make a std::deque of the type Entry before Entry is fully defined. This is nearly identical to the problem in the simplified C code below: struct foo { struct foo bar; } -- Eitan Adler