diff --git a/CMakeLists.txt b/CMakeLists.txt index ce937457..543b972d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,8 +75,19 @@ IF( MINGW OR UNIX ) -W ) ENDIF() - - IF ( CYGWIN ) + + if (CMAKE_COMPILER_IS_GNUCC) + execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion + OUTPUT_VARIABLE GCC_VERSION) + string(REGEX MATCHALL "[0-9]+" GCC_VERSION_COMPONENTS ${GCC_VERSION}) + list(GET GCC_VERSION_COMPONENTS 0 GCC_MAJOR) + list(GET GCC_VERSION_COMPONENTS 1 GCC_MINOR) + + message(STATUS Compiler major ${GCC_MAJOR}) + message(STATUS ${GCC_MINOR}) + endif() + + IF ( CYGWIN OR ( ${GCC_MAJOR} GREATER 5 )) ADD_DEFINITIONS( -std=gnu++98 ) # to support snprintf ELSE() ADD_DEFINITIONS( -std=c++98 ) diff --git a/config/configure.ac b/config/configure.ac index 1e0c6fd4..2dab6d35 100644 --- a/config/configure.ac +++ b/config/configure.ac @@ -335,6 +335,26 @@ for u in gettext msginit msgmerge msgfmt msgconv msgfilter ; do fi done +AC_DEFUN([AX_GCC_VERSION], [ + GCC_VERSION="" + AX_CHECK_COMPILE_FLAG([-dumpversion], + [ax_gcc_version_option=yes], + [ax_gcc_version_option=no]) + + AS_IF([test "x$GCC" = "xyes"],[ + AS_IF([test "x$ax_gcc_version_option" != "xno"],[ + AC_CACHE_CHECK([gcc version],[ax_cv_gcc_version],[ + ax_cv_gcc_version="`$CC -dumpversion`" + AS_IF([test "x$ax_cv_gcc_version" = "x"],[ + ax_cv_gcc_version="" + ]) + ]) + GCC_VERSION=$ax_cv_gcc_version + ]) + ]) + AC_SUBST([GCC_VERSION]) +]) + # 1188 v0.26 uses c++98 # 1188 v0.27 should have an option to specify versions such as c++11 case "$host_os" in @@ -345,7 +365,9 @@ case "$host_os" in CPPFLAGS="$CPPFLAGS" # mingw doesn't link pthreads if you specify -std !! ;; *) - CPPFLAGS="$CPPFLAGS -std=c++98" # // all others use c++98 + if [ $GCC_VERSION -le 5 ]; then CPPFLAGS="$CPPFLAGS -std=c++98" # // most others use c++98 + else CPPFLAGS="$CPPFLAGS -std=gnu++98" # // but not GCC 6 + fi ;; esac diff --git a/samples/Makefile b/samples/Makefile index 366c810b..8c4c17c8 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -123,7 +123,7 @@ LINK.cc += -rpath $(PREFIX) -L$(PREFIX) # to build the samples. Some errors only show up in this scenario, e.g., errors # due to missing headers which are not installed (depending on compile-time # settings) but may be wrongly included from other headers. -COMPILE.cc += -I$(top_srcdir)/include -I$(top_srcdir)/include/exiv2 +COMPILE.cc += -I$(top_srcdir)/include -I$(top_srcdir)/include/exiv2 -std=gnu++98 # ****************************************************************************** # Rules diff --git a/src/jpgimage.cpp b/src/jpgimage.cpp index 21d3d79e..7fa007f1 100644 --- a/src/jpgimage.cpp +++ b/src/jpgimage.cpp @@ -674,7 +674,8 @@ namespace Exiv2 { // and dumping the XMP in a post read operation similar to kpsIptcErase // for the moment, dumping 'on the fly' is working fine if ( ! bExtXMP ) { - while (xmp[start]) start++; start++; + while (xmp[start]) start++; + start++; if ( ::strstr((char*)xmp+start,"HasExtendedXMP") ) { start = size ; // ignore this packet, we'll get on the next time around bExtXMP = true; diff --git a/xmpsdk/src/XMPMeta-Serialize.cpp b/xmpsdk/src/XMPMeta-Serialize.cpp index 8cc96aec..70a7b020 100644 --- a/xmpsdk/src/XMPMeta-Serialize.cpp +++ b/xmpsdk/src/XMPMeta-Serialize.cpp @@ -1,5 +1,4 @@ -// ================================================================================================= -// Copyright 2002-2008 Adobe Systems Incorporated +// ================================================================================================= // Copyright 2002-2008 Adobe Systems Incorporated // All Rights Reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms @@ -284,7 +283,7 @@ AppendNodeValue ( XMP_VarString & outputStr, const XMP_VarString & value, bool f unsigned char * runStart = (unsigned char *) value.c_str(); unsigned char * runLimit = runStart + value.size(); unsigned char * runEnd; - unsigned char ch; + unsigned char ch=0; while ( runStart < runLimit ) {