From owner-freebsd-ports@FreeBSD.ORG Thu Jul 19 19:09:05 2012 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0F59C106564A for ; Thu, 19 Jul 2012 19:09:05 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (cl-327.ede-01.nl.sixxs.net [IPv6:2001:7b8:2ff:146::2]) by mx1.freebsd.org (Postfix) with ESMTP id B92DC8FC08 for ; Thu, 19 Jul 2012 19:09:04 +0000 (UTC) Received: from [IPv6:2001:7b8:3a7:0:915f:fe51:3cf1:9d19] (unknown [IPv6:2001:7b8:3a7:0:915f:fe51:3cf1:9d19]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 03DD15C37; Thu, 19 Jul 2012 21:09:03 +0200 (CEST) Message-ID: <50085B54.2040005@FreeBSD.org> Date: Thu, 19 Jul 2012 21:09:08 +0200 From: Dimitry Andric Organization: The FreeBSD Project User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: Jung-uk Kim References: <5006F780.2020004@FreeBSD.org> <44k3y1ndlp.fsf@be-well.ilk.org> <50073701.80205@FreeBSD.org> <500747F2.8010900@FreeBSD.org> <500809DA.1030301@FreeBSD.org> <50084CFA.9090802@gmail.com> In-Reply-To: <50084CFA.9090802@gmail.com> X-Enigmail-Version: 1.5a1pre Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: freebsd-ports@freebsd.org Subject: Re: [FYI] C++ compilers vs. __cplusplus (was Re: SV: Re: make failed for editors/libreoffice) X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Jul 2012 19:09:05 -0000 On 2012-07-19 20:07, Jung-uk Kim wrote: > On 2012-07-19 09:21:30 -0400, Dimitry Andric wrote: ... > Since when Clang started mimicking GCC 4.7? Most likely since somebody attempted to get the latest GNU libstdc++ building with clang, and bumped into precisely this issue: if __cplusplus has the simple value 1, you can't get libstdc++'s C++0x or C++11 support enabled. > % /usr/local/bin/clang++ -E -x c++ -dM /dev/null | grep __GNUC > #define __GNUC_GNU_INLINE__ 1 > #define __GNUC_MINOR__ 2 > #define __GNUC_PATCHLEVEL__ 1 > #define __GNUC__ 4 Yeah, that's probably the last gcc version clang is going to lie about, especially since version checking is very fragile. By the way, feature checks are implemented in clang using the __has_feature macro, which is much easier to use than comparing versions: http://clang.llvm.org/docs/LanguageExtensions.html#feature_check ... >> Well, this is what you get when standards progress to include >> non-standard features (such as gcc's "__null") that are already in >> use, but then subtly change them (calling them "nullptr"). > > Yes, it is subtle but it can cause a real trouble because NULL can > have different types depending on compiler versions and FreeBSD releases. > > % cat test.cc > #include > char *test = reinterpret_cast(NULL); > % clang++ -c test.cc > % clang++ -c -std=gnu++98 test.cc > % clang++ -c -std=gnu++0x test.cc > % clang++ -c -std=c++98 test.cc > % clang++ -c -std=c++0x test.cc > test.cc:2:14: error: reinterpret_cast from 'nullptr_t' to 'char *' is > not allowed > char *test = reinterpret_cast(NULL); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There is no need for casting at all here. 'nullptr' can implicitly be converted to any pointer type. If you really want to perform the cast, even when it is unnecessary, use static_cast<>, or a C-style cast. You only need to use reinterpret_cast<> here, if you want to convert 'nullptr' to any non-pointer type, such as int. Btw, does anybody know *why* the LibreOffice port attempts to compile everything as C++0x or C++11? Is it really using those features?