Date: Fri, 20 Sep 2013 10:20:02 +0200 From: Michael Gmelin <freebsd@grem.de> To: Shane Ambler <FreeBSD@ShaneWare.Biz> Cc: FreeBSD-ports <freebsd-ports@freebsd.org> Subject: Re: libc++ differences between 9.2 and 10.0 Message-ID: <20130920102002.74f42edf@bsd64.grem.de> In-Reply-To: <523BDDCE.4060801@ShaneWare.Biz> References: <523BDDCE.4060801@ShaneWare.Biz>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 20 Sep 2013 15:01:58 +0930 Shane Ambler <FreeBSD@ShaneWare.Biz> 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 <memory> > #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++. 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. 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). Cheers, Michael > > > _______________________________________________ > freebsd-ports@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-ports > To unsubscribe, send any mail to > "freebsd-ports-unsubscribe@freebsd.org" -- Michael Gmelin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130920102002.74f42edf>