Kaydet (Commit) 0032fc03 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Fix check for broken standard library

The compiler's __GNUC__ etc. need not match the libstdc++ version used (esp.
when using Clang as compiler), and libstdc++'s __GLIBCXX__ macro doesn't inrease
monotonically with version numbers, so resort to a configure check.

Change-Id: I06de6b68324169863f6f5c31ae5d855e8b04cd6b
üst a38f8c22
......@@ -22,6 +22,7 @@ Any change in this header will cause a rebuild of almost everything.
#define HAVE_GCC_PRAGMA_OPERATOR 0
#define HAVE_GCC_DEPRECATED_MESSAGE 0
#define HAVE_THREADSAFE_STATICS 0
#define HAVE_BROKEN_CONST_ITERATORS 0
#define HAVE_BROKEN_STATIC_INITILIZER_LIST 0
#define HAVE_SYSLOG_H 0
/* Compiler supports __attribute__((warn_unused)). */
......
......@@ -12764,6 +12764,27 @@ if test "$build_os" = "cygwin"; then
AC_SUBST(ILIB)
fi
AC_MSG_CHECKING(
[whether C++11 use of const_iterator in standard containers is broken])
save_CXXFLAGS=$CXXFLAGS
CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <list>
]],[[
std::list<int> l;
l.erase(l.cbegin());
]])],
[broken=no], [broken=yes])
AC_LANG_POP([C++])
LIBS=$save_LIBS
CXXFLAGS=$save_CXXFLAGS
AC_MSG_RESULT([$broken])
if test "$broken" = yes; then
AC_DEFINE([HAVE_BROKEN_CONST_ITERATORS])
fi
AC_MSG_CHECKING([whether $CXX has broken static initializer_list support])
if test "$CROSS_COMPILING" = "TRUE"; then
broken='assuming not (cross-compiling)'
......
......@@ -28,7 +28,7 @@
#include "basegfx/polygon/b2dpolypolygontools.hxx"
#include "basegfx/range/b2drange.hxx"
#include <config_global.h>
#include <osl/diagnose.h>
#include "com/sun/star/i18n/BreakIterator.hpp"
#include "com/sun/star/i18n/CharacterClassification.hpp"
......@@ -452,7 +452,7 @@ void DrawXmlOptimizer::visit( PolyPolyElement& elem, const std::list< Element* >
elem.Children.splice( elem.Children.end(), pNext->Children );
// workaround older compilers that do not have std::list::erase(const_iterator)
#if defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ <= 8
#if HAVE_BROKEN_CONST_ITERATORS
std::list< Element* >::iterator tmpIt = elem.Parent->Children.begin();
std::advance(tmpIt, std::distance(elem.Parent->Children.cbegin(), next_it));
elem.Parent->Children.erase(tmpIt);
......
......@@ -28,6 +28,7 @@
#include "basegfx/polygon/b2dpolypolygontools.hxx"
#include "basegfx/range/b2drange.hxx"
#include <config_global.h>
#include <osl/diagnose.h>
using namespace ::com::sun::star;
......@@ -403,7 +404,7 @@ void WriterXmlOptimizer::visit( PolyPolyElement& elem, const std::list< Element*
elem.Children.splice( elem.Children.end(), pNext->Children );
// workaround older compilers that do not have std::list::erase(const_iterator)
#if defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ <= 8
#if HAVE_BROKEN_CONST_ITERATORS
std::list< Element* >::iterator tmpIt = elem.Parent->Children.begin();
std::advance(tmpIt, std::distance(elem.Parent->Children.cbegin(), next_it));
elem.Parent->Children.erase(tmpIt);
......
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