From owner-freebsd-ports@FreeBSD.ORG Fri Sep 20 11:16:41 2013 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 37ED11F7 for ; Fri, 20 Sep 2013 11:16:41 +0000 (UTC) (envelope-from FreeBSD@shaneware.biz) Received: from ipmail04.adl6.internode.on.net (ipmail04.adl6.internode.on.net [IPv6:2001:44b8:8060:ff02:300:1:6:4]) by mx1.freebsd.org (Postfix) with ESMTP id C43C42F81 for ; Fri, 20 Sep 2013 11:16:40 +0000 (UTC) Received: from ppp118-210-231-94.lns20.adl6.internode.on.net (HELO leader.local) ([118.210.231.94]) by ipmail04.adl6.internode.on.net with ESMTP; 20 Sep 2013 20:46:39 +0930 Message-ID: <523C2E93.5010104@ShaneWare.Biz> Date: Fri, 20 Sep 2013 20:46:35 +0930 From: Shane Ambler User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:17.0) Gecko/20130516 Thunderbird/17.0.6 MIME-Version: 1.0 To: Michael Gmelin Subject: Re: libc++ differences between 9.2 and 10.0 References: <523BDDCE.4060801@ShaneWare.Biz> <20130920102002.74f42edf@bsd64.grem.de> In-Reply-To: <20130920102002.74f42edf@bsd64.grem.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: FreeBSD-ports X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Sep 2013 11:16:41 -0000 On 20/09/2013 17:50, Michael Gmelin wrote: > On Fri, 20 Sep 2013 15:01:58 +0930 > Shane Ambler wrote: > >> I'm Starting to look at fixing my ports to build on 10.0 and there >> appears to be a difference between 9.2 and 10.0 when it comes to >> using libc++ >> >> The first port I am looking at is graphics/opencolorio. a patch was >> submitted (ports/182220) that works fine on 10.0 but it breaks 9.2 >> build when using clang with - >> error: no type named 'shared_ptr' in namespace 'std' >> >> The patch is simple, just adding - >> >> #elif __cplusplus >= 199711 >> #include >> #define OCIO_SHARED_PTR std::shared_ptr >> #define OCIO_DYNAMIC_POINTER_CAST std::dynamic_pointer_cast >> >> As far as I can see both 10.0 and 9.2 use the same contrib/libc++ >> contents but I don't see why 9.2 isn't finding std::shared_ptr >> >> >> The other thing is I don't think testing __cplusplus is the right way >> to go but don't see an alternative. __cplusplus is defined in clang >> irrespective of the library used so isn't really a reliable test. >> >> Are there any defines to easily test for std::shared_ptr or is that a >> test I need to create for configure or cmake - has already been done? > > Hi Shane, > > I looks like you're using libstdc++ on 9.2 (the version that comes with > gcc 4.2). To build with libc++ you need to use > > CXXFLAGS+= -std=c++11 -stdlib=libc++. I tried adding that to the Makefile as well as LDFLAGS+= -stdlib=libc++ Just realised that I put them in a test for OSVERSION between 901000 and 100000 - missed a zero for 10 so it wasn't used ;-) my fault > Checking for _cplusplus isn't enough, since this only checks for the > language standard, but not for standard c++ library used. > > First you should check for a C++11 enabled compiled (you're checking > for C++98, which didn't standardize std::shared_ptr) > > #elif __cplusplus >= 201103 > > Then you should also check which standard library is used (in the end > you can mix clang C++11 and an old C++ standard library): > > #elif _cplusplus >= 201103 && defined(_LIBCPP_VERSION) > > This checks if libc++ is used. > > Since all relevant version of libc++ support C++11 features like > shared_ptr this should be good enough. That sounds like a reasonable option. > If you want to stay compatible with newer versions of gcc and libstdc++ > you'll have to figure out how to check for this as well (unfortunately > I can't tell the exact checks to use from the top of my head). > This expands tests for OCIO_USE_BOOST_PTR (windows) and __GNUC__ choosing between boost::shared_ptr and std::tr1:;shareed_ptr