Skip to content
Snippets Groups Projects
Commit 2ac6e1ad authored by Giovanni Bussi's avatar Giovanni Bussi
Browse files

Enable c++11 syntax.

This requires a few fixes:
- Replace -ansi with -std=c++11 in autoconf.
- Add a check that c++11 is supported in autoconf.
- Change flags for cppcheck.
- Remove travis configurations that would fail.

Additionally, I removed the check for 'explicit' keyword,
which is not needed with C++11.

Fixes #212
parent 549bd3bc
No related branches found
No related tags found
No related merge requests found
......@@ -30,11 +30,6 @@ matrix:
dist: trusty
sudo: required
env: PLUMED_CC=gcc PLUMED_CXX=g++ PLUMED_CXXFLAGS=-O3 LAPACK=yes
# then I try serial compiler on UBUNTU precise
- os: linux
dist: precise
sudo: required
env: PLUMED_CC=gcc PLUMED_CXX=g++
# test using external blas with internal lapack
- os: linux
dist: trusty
......
......@@ -4443,9 +4443,9 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -ansi"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -ansi" >&5
$as_echo_n "checking whether $CXX accepts -ansi... " >&6; }
CXXFLAGS="$CXXFLAGS -std=c++11"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -std=c++11" >&5
$as_echo_n "checking whether $CXX accepts -std=c++11... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
......@@ -5056,11 +5056,15 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports explicit" >&5
$as_echo_n "checking whether $CXX supports explicit... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX declares c++11 support" >&5
$as_echo_n "checking whether $CXX declares c++11 support... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
class A{explicit A(){}};
#if __cplusplus <= 199711L
this_compiler_does_not_support_cxx11
#endif
int
main ()
{
......@@ -5075,13 +5079,14 @@ $as_echo "yes" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; } ;
$as_echo "#define explicit /**/" >>confdefs.h
as_fn_error $? "C++11 support is required" "$LINENO" 5
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
if test "$dependency_tracking" = true
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX can generate dependency file with -MM -MF" >&5
......
......@@ -252,7 +252,7 @@ if test $basic_warnings == true
then
PLUMED_CHECK_CXXFLAG([-Wall])
PLUMED_CHECK_CXXFLAG([-pedantic])
PLUMED_CHECK_CXXFLAG([-ansi])
PLUMED_CHECK_CXXFLAG([-std=c++11])
fi
if test $debug == true
......@@ -282,11 +282,17 @@ then
PLUMED_CHECK_CXXFLAG([-Wold-style-cast])
fi
AC_MSG_CHECKING([whether $CXX supports explicit])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ class A{explicit A(){}};])],
AC_MSG_CHECKING([whether $CXX declares c++11 support])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
#if __cplusplus <= 199711L
this_compiler_does_not_support_cxx11
#endif
])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no]) ;
AC_DEFINE([explicit],[])])
AC_MSG_ERROR([C++11 support is required])])
AC_SUBST(disable_dependency_tracking)
......
......@@ -34,7 +34,7 @@ if [ $do_cppcheck == true ] ; then
else
files="$(echo */*.{h,cpp})"
fi
cppcheck --std=c++03 --std=posix 4 -j 4 --platform=unix64 \
cppcheck --std=c++11 --std=posix 4 -j 4 --platform=unix64 \
--template='[{file}:{line}] ({severity}) :{id}: {message}' --enable=all --inline-suppr --force \
$files
fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment