Commit 2f76f9da authored by Max Kellermann's avatar Max Kellermann

configure.ac: enable C++14

parent b0b8f573
...@@ -53,6 +53,8 @@ ver 0.20 (not yet released) ...@@ -53,6 +53,8 @@ ver 0.20 (not yet released)
- proxy: add TCP keepalive option - proxy: add TCP keepalive option
* update * update
- apply .mpdignore matches to subdirectories - apply .mpdignore matches to subdirectories
* switch the code base to C++14
- GCC 4.9 or clang 3.4 (or newer) recommended
ver 0.19.20 (not yet released) ver 0.19.20 (not yet released)
* decoder * decoder
......
...@@ -186,14 +186,7 @@ dnl --------------------------------------------------------------------------- ...@@ -186,14 +186,7 @@ dnl ---------------------------------------------------------------------------
dnl Language Checks dnl Language Checks
dnl --------------------------------------------------------------------------- dnl ---------------------------------------------------------------------------
AC_CXX_COMPILE_STDCXX_0X AX_CXX_COMPILE_STDCXX_14([noext], [mandatory])
if test "$ax_cv_cxx_compile_cxx0x_native" != yes; then
if test "$ax_cv_cxx_compile_cxx0x_gxx" = yes; then
AM_CXXFLAGS="$AM_CXXFLAGS -std=gnu++0x"
elif test "$ax_cv_cxx_compile_cxx0x_cxx" = yes; then
AM_CXXFLAGS="$AM_CXXFLAGS -std=c++0x"
fi
fi
dnl --------------------------------------------------------------------------- dnl ---------------------------------------------------------------------------
dnl Header/Library Checks dnl Header/Library Checks
......
...@@ -41,8 +41,8 @@ ...@@ -41,8 +41,8 @@
<listitem> <listitem>
<para> <para>
the code should be C++11 compliant, and must compile with the code should be C++11 compliant, and must compile with
<application>GCC</application> 4.7 and <application>GCC</application> 4.9 and
<application>clang</application> 3.2 <application>clang</application> 3.4
</para> </para>
</listitem> </listitem>
......
# ============================================================================
# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_0x.html
# ============================================================================
#
# SYNOPSIS
#
# AX_CXX_COMPILE_STDCXX_0X
#
# DESCRIPTION
#
# Check for baseline language coverage in the compiler for the C++0x
# standard.
#
# LICENSE
#
# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 8
AU_ALIAS([AC_CXX_COMPILE_STDCXX_0X], [AX_CXX_COMPILE_STDCXX_0X])
AC_DEFUN([AX_CXX_COMPILE_STDCXX_0X], [
AC_CACHE_CHECK(if g++ supports C++0x features without additional flags,
ax_cv_cxx_compile_cxx0x_native,
[AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_TRY_COMPILE([
template <typename T>
struct check
{
static_assert(sizeof(int) <= sizeof(T), "not big enough");
};
typedef check<check<bool>> right_angle_brackets;
int a;
decltype(a) b;
typedef check<int> check_type;
check_type c;
check_type&& cr = static_cast<check_type&&>(c);],,
ax_cv_cxx_compile_cxx0x_native=yes, ax_cv_cxx_compile_cxx0x_native=no)
AC_LANG_RESTORE
])
AC_CACHE_CHECK(if g++ supports C++0x features with -std=c++0x,
ax_cv_cxx_compile_cxx0x_cxx,
[AC_LANG_SAVE
AC_LANG_CPLUSPLUS
ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -std=c++0x"
AC_TRY_COMPILE([
template <typename T>
struct check
{
static_assert(sizeof(int) <= sizeof(T), "not big enough");
};
typedef check<check<bool>> right_angle_brackets;
int a;
decltype(a) b;
typedef check<int> check_type;
check_type c;
check_type&& cr = static_cast<check_type&&>(c);],,
ax_cv_cxx_compile_cxx0x_cxx=yes, ax_cv_cxx_compile_cxx0x_cxx=no)
CXXFLAGS="$ac_save_CXXFLAGS"
AC_LANG_RESTORE
])
AC_CACHE_CHECK(if g++ supports C++0x features with -std=gnu++0x,
ax_cv_cxx_compile_cxx0x_gxx,
[AC_LANG_SAVE
AC_LANG_CPLUSPLUS
ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -std=gnu++0x"
AC_TRY_COMPILE([
template <typename T>
struct check
{
static_assert(sizeof(int) <= sizeof(T), "not big enough");
};
typedef check<check<bool>> right_angle_brackets;
int a;
decltype(a) b;
typedef check<int> check_type;
check_type c;
check_type&& cr = static_cast<check_type&&>(c);],,
ax_cv_cxx_compile_cxx0x_gxx=yes, ax_cv_cxx_compile_cxx0x_gxx=no)
CXXFLAGS="$ac_save_CXXFLAGS"
AC_LANG_RESTORE
])
if test "$ax_cv_cxx_compile_cxx0x_native" = yes ||
test "$ax_cv_cxx_compile_cxx0x_cxx" = yes ||
test "$ax_cv_cxx_compile_cxx0x_gxx" = yes; then
AC_DEFINE(HAVE_STDCXX_0X,,[Define if g++ supports C++0x features. ])
fi
])
# ============================================================================
# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_14.html
# ============================================================================
#
# SYNOPSIS
#
# AX_CXX_COMPILE_STDCXX_14([ext|noext], [mandatory|optional])
#
# DESCRIPTION
#
# Check for baseline language coverage in the compiler for the C++14
# standard; if necessary, add switches to CXX and CXXCPP to enable
# support.
#
# This macro is a convenience alias for calling the AX_CXX_COMPILE_STDCXX
# macro with the version set to C++14. The two optional arguments are
# forwarded literally as the second and third argument respectively.
# Please see the documentation for the AX_CXX_COMPILE_STDCXX macro for
# more information. If you want to use this macro, you also need to
# download the ax_cxx_compile_stdcxx.m4 file.
#
# LICENSE
#
# Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 4
AX_REQUIRE_DEFINED([AX_CXX_COMPILE_STDCXX])
AC_DEFUN([AX_CXX_COMPILE_STDCXX_14], [AX_CXX_COMPILE_STDCXX([14], [$1], [$2])])
...@@ -20,19 +20,10 @@ ...@@ -20,19 +20,10 @@
#ifndef MPD_CHRONO_HXX #ifndef MPD_CHRONO_HXX
#define MPD_CHRONO_HXX #define MPD_CHRONO_HXX
#include "Compiler.h"
#include <chrono> #include <chrono>
#include <utility> #include <utility>
#include <cstdint> #include <cstdint>
#if GCC_OLDER_THAN(4,7)
/* std::chrono::duration operators are "constexpr" since gcc 4.7 */
#define chrono_constexpr gcc_pure
#else
#define chrono_constexpr constexpr
#endif
/** /**
* A time stamp within a song. Granularity is 1 millisecond and the * A time stamp within a song. Granularity is 1 millisecond and the
* maximum value is about 49 days. * maximum value is about 49 days.
...@@ -108,11 +99,11 @@ public: ...@@ -108,11 +99,11 @@ public:
return count() > 0; return count() > 0;
} }
chrono_constexpr SongTime operator+(const SongTime &other) const { constexpr SongTime operator+(const SongTime &other) const {
return SongTime(*(const Base *)this + (const Base &)other); return SongTime(*(const Base *)this + (const Base &)other);
} }
chrono_constexpr SongTime operator-(const SongTime &other) const { constexpr SongTime operator-(const SongTime &other) const {
return SongTime(*(const Base *)this - (const Base &)other); return SongTime(*(const Base *)this - (const Base &)other);
} }
}; };
...@@ -212,15 +203,13 @@ public: ...@@ -212,15 +203,13 @@ public:
return count() < 0; return count() < 0;
} }
chrono_constexpr SignedSongTime operator+(const SignedSongTime &other) const { constexpr SignedSongTime operator+(const SignedSongTime &other) const {
return SignedSongTime(*(const Base *)this + (const Base &)other); return SignedSongTime(*(const Base *)this + (const Base &)other);
} }
chrono_constexpr SignedSongTime operator-(const SignedSongTime &other) const { constexpr SignedSongTime operator-(const SignedSongTime &other) const {
return SignedSongTime(*(const Base *)this - (const Base &)other); return SignedSongTime(*(const Base *)this - (const Base &)other);
} }
}; };
#undef chrono_constexpr
#endif #endif
...@@ -62,8 +62,8 @@ ...@@ -62,8 +62,8 @@
# error Sorry, your clang version is too old. You need at least version 3.1. # error Sorry, your clang version is too old. You need at least version 3.1.
# endif # endif
#elif defined(__GNUC__) #elif defined(__GNUC__)
# if GCC_OLDER_THAN(4,7) # if GCC_OLDER_THAN(4,9)
# error Sorry, your gcc version is too old. You need at least version 4.6. # error Sorry, your gcc version is too old. You need at least version 4.9.
# endif # endif
#else #else
# warning Untested compiler. Use at your own risk! # warning Untested compiler. Use at your own risk!
...@@ -97,8 +97,6 @@ ...@@ -97,8 +97,6 @@
#define gcc_likely(x) __builtin_expect (!!(x), 1) #define gcc_likely(x) __builtin_expect (!!(x), 1)
#define gcc_unlikely(x) __builtin_expect (!!(x), 0) #define gcc_unlikely(x) __builtin_expect (!!(x), 0)
#define gcc_aligned(n) __attribute__((aligned(n)))
#define gcc_visibility_hidden __attribute__((visibility("hidden"))) #define gcc_visibility_hidden __attribute__((visibility("hidden")))
#define gcc_visibility_default __attribute__((visibility("default"))) #define gcc_visibility_default __attribute__((visibility("default")))
...@@ -126,8 +124,6 @@ ...@@ -126,8 +124,6 @@
#define gcc_likely(x) (x) #define gcc_likely(x) (x)
#define gcc_unlikely(x) (x) #define gcc_unlikely(x) (x)
#define gcc_aligned(n)
#define gcc_visibility_hidden #define gcc_visibility_hidden
#define gcc_visibility_default #define gcc_visibility_default
...@@ -168,17 +164,7 @@ ...@@ -168,17 +164,7 @@
#if defined(__cplusplus) #if defined(__cplusplus)
/* support for C++11 "override" was added in gcc 4.7 */
#if GCC_OLDER_THAN(4,7)
#define override
#define final
#endif
#if CLANG_OR_GCC_VERSION(4,8)
#define gcc_alignas(T, fallback) alignas(T) #define gcc_alignas(T, fallback) alignas(T)
#else
#define gcc_alignas(T, fallback) gcc_aligned(fallback)
#endif
#endif #endif
......
...@@ -35,10 +35,6 @@ ...@@ -35,10 +35,6 @@
#include <new> #include <new>
#include <utility> #include <utility>
#if GCC_OLDER_THAN(4,8)
#include <type_traits>
#endif
#include <assert.h> #include <assert.h>
#if CLANG_OR_GCC_VERSION(4,7) #if CLANG_OR_GCC_VERSION(4,7)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment