summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2005-01-19 16:05:50 +0000
committerMurray Cumming <murrayc@src.gnome.org>2005-01-19 16:05:50 +0000
commita07a93a6726ddd09ebd0aaadbeef4027677047ab (patch)
tree066bb0eaf0412fb1843a2e672c5b9d4853f1582e
parent0a181eee2929f5f8c4bddeabbea82d17a04f1dc7 (diff)
downloadglibmm-a07a93a6726ddd09ebd0aaadbeef4027677047ab.tar.gz
Added a compiler test, because the IRIX MipsPro compiler does not allow
2005-01-19 Murray Cumming <murrayc@murrayc.com> * configure.in, scripts/cxx.m4, glibmm/glibmmconfig.h.in: Added a compiler test, because the IRIX MipsPro compiler does not allow the inline initialization of ustring::npos. * glib/glibmm/ustring.[h|cc]: When the compiler does not support the inline initialization of npos, initialize it in the .cc file. Declare partial specializatoins of the SequenceString inner class inside the class - needed by MipsPro (IRIX) compiler..
-rw-r--r--ChangeLog10
-rw-r--r--configure.in1
-rw-r--r--glib/glibmm/ustring.cc7
-rw-r--r--glib/glibmm/ustring.h30
-rw-r--r--glib/glibmmconfig.h.in2
-rw-r--r--scripts/cxx_std.m441
-rw-r--r--tests/glibmm_value/glibmm_value.cc2
7 files changed, 86 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index c4a988f9..c0e2868b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2005-01-19 Murray Cumming <murrayc@murrayc.com>
+
+ * configure.in, scripts/cxx.m4, glibmm/glibmmconfig.h.in: Added a
+ compiler test, because the IRIX MipsPro compiler does not allow the
+ inline initialization of ustring::npos.
+ * glib/glibmm/ustring.[h|cc]: When the compiler does not support the
+ inline initialization of npos, initialize it in the .cc file.
+ Declare partial specializatoins of the SequenceString inner class
+ inside the class - needed by MipsPro (IRIX) compiler..
+
2004-12-11 Cedric Gustin <cedric.gustin@swing.be>
* configure.in : parse version tags at configure time (for
diff --git a/configure.in b/configure.in
index c75d8700..bb2e6456 100644
--- a/configure.in
+++ b/configure.in
@@ -194,6 +194,7 @@ GLIBMM_CXX_HAS_SUN_REVERSE_ITERATOR()
GLIBMM_CXX_HAS_TEMPLATE_SEQUENCE_CTORS()
GLIBMM_CXX_MEMBER_FUNCTIONS_MEMBER_TEMPLATES()
GLIBMM_CXX_CAN_DISAMBIGUATE_CONST_TEMPLATE_SPECIALIZATIONS()
+GLIBMM_CXX_ALLOWS_STATIC_INLINE_NPOS()
# Create a list of input directories for Doxygen.
GTKMM_DOXYGEN_INPUT_SUBDIRS([glib])
diff --git a/glib/glibmm/ustring.cc b/glib/glibmm/ustring.cc
index f483d3ed..c3467805 100644
--- a/glib/glibmm/ustring.cc
+++ b/glib/glibmm/ustring.cc
@@ -35,7 +35,6 @@ namespace
using Glib::ustring;
-
// Little helper to make the conversion from gunichar to UTF-8 a one-liner.
//
struct UnicharToUtf8
@@ -215,6 +214,12 @@ ustring::size_type utf8_find_last_of(const std::string& str, ustring::size_type
namespace Glib
{
+#ifndef GLIBMM_HAVE_ALLOWS_STATIC_INLINE_NPOS
+// Initialize static member here,
+// because the compiler did not allow us do it inline.
+const ustring::size_type ustring::npos = std::string::npos;
+#endif
+
// We need our own version of g_utf8_get_char(), because the std::string
// iterator is not necessarily a plain pointer (it's in fact not in GCC's
// libstdc++-v3). Copying the UTF-8 data into a temporary buffer isn't an
diff --git a/glib/glibmm/ustring.h b/glib/glibmm/ustring.h
index 0269c9e5..d000a25b 100644
--- a/glib/glibmm/ustring.h
+++ b/glib/glibmm/ustring.h
@@ -232,7 +232,13 @@ public:
#endif /* GLIBMM_HAVE_SUN_REVERSE_ITERATOR */
+#ifdef GLIBMM_HAVE_ALLOWS_STATIC_INLINE_NPOS
static const size_type npos = std::string::npos;
+#else
+ //The MipsPro compiler (IRIX) says "The indicated constant value is not known",
+ //so we need to initalize the static member data elsewhere.
+ static const size_type npos;
+#endif
/*! Default constructor, which creates an empty string.
*/
@@ -578,7 +584,23 @@ private:
template <class In, class ValueType = typename Glib::IteratorTraits<In>::value_type>
#endif
struct SequenceToString;
+
+ //The MipsPro (IRIX) compiler needs these partial specializations to be declared here,
+ //as well as defined later. That's probably correct. murrayc.
+ template <class In>
+ struct SequenceToString<In, char>;
+ template <class In>
+ struct SequenceToString<In, gunichar>;
+
+ /*
+ template <>
+ struct ustring::SequenceToString<Glib::ustring::iterator, gunichar>;
+
+ template <>
+ struct ustring::SequenceToString<Glib::ustring::const_iterator, gunichar>;
+ */
+
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
std::string string_;
@@ -592,25 +614,25 @@ struct ustring::SequenceToString
{};
template <class In>
-struct ustring::SequenceToString<In,char> : public std::string
+struct ustring::SequenceToString<In, char> : public std::string
{
SequenceToString(In pbegin, In pend);
};
template <class In>
-struct ustring::SequenceToString<In,gunichar> : public std::string
+struct ustring::SequenceToString<In, gunichar> : public std::string
{
SequenceToString(In pbegin, In pend);
};
template <>
-struct ustring::SequenceToString<Glib::ustring::iterator,gunichar> : public std::string
+struct ustring::SequenceToString<Glib::ustring::iterator, gunichar> : public std::string
{
SequenceToString(Glib::ustring::iterator pbegin, Glib::ustring::iterator pend);
};
template <>
-struct ustring::SequenceToString<Glib::ustring::const_iterator,gunichar> : public std::string
+struct ustring::SequenceToString<Glib::ustring::const_iterator, gunichar> : public std::string
{
SequenceToString(Glib::ustring::const_iterator pbegin, Glib::ustring::const_iterator pend);
};
diff --git a/glib/glibmmconfig.h.in b/glib/glibmmconfig.h.in
index 3a06a02d..9473a2b1 100644
--- a/glib/glibmmconfig.h.in
+++ b/glib/glibmmconfig.h.in
@@ -58,6 +58,8 @@
# define GLIBMM_USING_STD(Symbol) /* empty */
#endif
+#undef GLIBMM_HAVE_ALLOWS_STATIC_INLINE_NPOS
+
#ifdef GLIBMM_DLL
#if defined(GLIBMM_BUILD) && defined(_WINDLL)
/* Do not dllexport as it is handled by gendef on MSVC */
diff --git a/scripts/cxx_std.m4 b/scripts/cxx_std.m4
index 1a36305c..2ccb88fc 100644
--- a/scripts/cxx_std.m4
+++ b/scripts/cxx_std.m4
@@ -151,4 +151,45 @@ AC_DEFUN([GLIBMM_CXX_HAS_TEMPLATE_SEQUENCE_CTORS],
fi
])
+## GLIBMM_CXX_ALLOWS_STATIC_INLINE_NPOS()
+##
+## Check whether the a static member variable may be initialized inline to std::string::npos.
+## The MipsPro (IRIX) compiler does not like this.
+## and #define GLIBMM_HAVE_ALLOWS_STATIC_INLINE_NPOS on success.
+##
+AC_DEFUN([GLIBMM_CXX_ALLOWS_STATIC_INLINE_NPOS],
+[
+ AC_REQUIRE([GLIBMM_CXX_HAS_NAMESPACE_STD])
+
+ AC_CACHE_CHECK(
+ [whether the compiler allows a static member variable to be initialized inline to std::string::npos],
+ [gtkmm_cv_cxx_has_allows_static_inline_npos],
+ [
+ AC_TRY_COMPILE(
+ [
+ #include <string>
+ #include <iostream>
+
+ class ustringtest
+ {
+ public:
+ //The MipsPro compiler (IRIX) says "The indicated constant value is not known",
+ //so we need to initalize the static member data elsewhere.
+ static const std::string::size_type ustringnpos = std::string::npos;
+ };
+ ],[
+ std::cout << "npos=" << ustringtest::ustringnpos << std::endl;
+ ],
+ [gtkmm_cv_cxx_has_allows_static_inline_npos="yes"],
+ [gtkmm_cv_cxx_has_allows_static_inline_npos="no"]
+ )
+ ])
+
+ if test "x${gtkmm_cv_cxx_has_allows_static_inline_npos}" = "xyes"; then
+ {
+ AC_DEFINE([GLIBMM_HAVE_ALLOWS_STATIC_INLINE_NPOS],[1, [Defined if a static member variable may be initialized inline to std::string::npos]])
+ }
+ fi
+])
+
diff --git a/tests/glibmm_value/glibmm_value.cc b/tests/glibmm_value/glibmm_value.cc
index b8f4e781..b3bf759a 100644
--- a/tests/glibmm_value/glibmm_value.cc
+++ b/tests/glibmm_value/glibmm_value.cc
@@ -1,7 +1,5 @@
#include <glibmm.h>
-//#include <gdkmm.h>
-//#include <gtkmm.h>
struct Foo
{