From owner-freebsd-current@FreeBSD.ORG Tue Nov 12 17:10:03 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 CD5696CF for ; Tue, 12 Nov 2013 17:10:03 +0000 (UTC) Received: from theravensnest.org (theraven.freebsd.your.org [216.14.102.27]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 870A42D7F for ; Tue, 12 Nov 2013 17:10:03 +0000 (UTC) Received: from [192.168.0.2] (cpc27-cmbg15-2-0-cust235.5-4.cable.virginm.net [86.27.188.236]) (authenticated bits=0) by theravensnest.org (8.14.5/8.14.5) with ESMTP id rACHA0UX010014 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Tue, 12 Nov 2013 17:10:02 GMT (envelope-from theraven@FreeBSD.org) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 6.5 \(1508\)) Subject: Re: Are clang++ and libc++ compatible? From: David Chisnall In-Reply-To: <20131112165422.GA2939@troutmask.apl.washington.edu> Date: Tue, 12 Nov 2013 17:09:54 +0000 Content-Transfer-Encoding: quoted-printable Message-Id: <48CC87B2-C2D2-44F8-A7DE-4D870E68E7D9@FreeBSD.org> References: <20131112163219.GA2834@troutmask.apl.washington.edu> <77CB2B92-216A-4C80-B033-7E582B5F0DFC@FreeBSD.org> <20131112165422.GA2939@troutmask.apl.washington.edu> To: Steve Kargl X-Mailer: Apple Mail (2.1508) Cc: freebsd-current@FreeBSD.org 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 17:10:03 -0000 On 12 Nov 2013, at 16:54, 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: >>=20 >>> Trying to build news/pan with clang++ dies with >>>=20 >>> 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 =3D sizeof(value_type) < = 256 ? 4... >>>=20 >>> Anyone know how to fix either clang++ or libc++? >>=20 >> 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. >>=20 >=20 > 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. Yes, that's normal in C++ too. > 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) >=20 > #ifndef __Log_h__ > #define __Log_h__ >=20 > #include > #include > #include > #include >=20 > namespace pan > { > class Log > { > public: > enum Severity { > PAN_SEVERITY_INFO =3D 1, > PAN_SEVERITY_ERROR =3D 2, > PAN_SEVERITY_URGENT =3D (1<<10) > }; >=20 > struct Entry { > time_t date; > Severity severity; > std::deque messages; > std::string message; > bool is_child; > Entry() : is_child(false) { } > }; >=20 > void add_entry(Entry& e, std::deque& list); >=20 >=20 > Are you saying that I need to move '#include ' to > the location above the 'void add_entry(...)' line? No, I'm saying that the definition of struct Entry needs to be complete = before its use in the specialisation of std::deque. =20 I'd perhaps be able to be more helpful if you hadn't removed from the = error message the part that tells you where the error actually is... David