From 3c4f93cf24e513e764b029306080fcdf20d96296 Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Thu, 2 Mar 2017 00:46:20 -0600 Subject: [PATCH] Cpp11 (#3731) * Enabled c++11 support (required for IO::AMF), extended Travis build to build with g++ 4.9 * ifdef guard in poly2tri/util to avoid redefinition warning * cache local-lib --- .travis.yml | 7 ++++++- xs/Build.PL | 7 ++++++- xs/src/poly2tri/common/utils.h | 4 +++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8e9616ab54..2d84fd28df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,13 +11,18 @@ branches: - stable sudo: false cache: - - apt + apt: true + directories: + - local-lib addons: apt: sources: - boost-latest + - ubuntu-toolchain-r-test packages: - libboost-thread1.55-dev - libboost-system1.55-dev - libboost-filesystem1.55-dev - liblocal-lib-perl + - g++-4.9 +env: CC=g++-4.9 diff --git a/xs/Build.PL b/xs/Build.PL index deb8dad658..557a5fd451 100644 --- a/xs/Build.PL +++ b/xs/Build.PL @@ -15,8 +15,13 @@ my $mswin = $^O eq 'MSWin32'; # HAS_BOOL : stops Perl/lib/CORE/handy.h from doing "# define bool char" for MSVC # NOGDI : prevents inclusion of wingdi.h which defines functions Polygon() and Polyline() in global namespace # BOOST_ASIO_DISABLE_KQUEUE : prevents a Boost ASIO bug on OS X: https://svn.boost.org/trac/boost/ticket/5339 +# std=c++11 Enforce usage of C++11 (required now). Minimum compiler supported: gcc 4.9, clang 3.3, MSVC 14.0 my @cflags = qw(-D_GLIBCXX_USE_C99 -DHAS_BOOL -DNOGDI -DSLIC3RXS -DBOOST_ASIO_DISABLE_KQUEUE - -Wno-c++11-extensions); + -std=c++11); +if ($cpp_guess->is_gcc) { + # GCC is pedantic with c++11 std, so undefine strict ansi to get M_PI back + push @cflags, qw(-U__STRICT_ANSI__); +} my @ldflags = (); if ($^O eq 'darwin') { push @ldflags, qw(-framework IOKit -framework CoreFoundation); diff --git a/xs/src/poly2tri/common/utils.h b/xs/src/poly2tri/common/utils.h index ffb713f58f..b4dfec4c48 100644 --- a/xs/src/poly2tri/common/utils.h +++ b/xs/src/poly2tri/common/utils.h @@ -33,7 +33,9 @@ #define UTILS_H // Otherwise #defines like M_PI are undeclared under Visual Studio +#ifndef _USE_MATH_DEFINES #define _USE_MATH_DEFINES +#endif #include #include @@ -119,4 +121,4 @@ bool InScanArea(const Point& pa, const Point& pb, const Point& pc, const Point& } -#endif \ No newline at end of file +#endif