From fc5dee54794469479a7f882d90345d2dea86eeb4 Mon Sep 17 00:00:00 2001
From: Marco Biasini <marco.biasini@unibas.ch>
Date: Thu, 6 Oct 2011 17:37:18 +0200
Subject: [PATCH] fix compilation with gcc 4.1

For quite some time, gcc 4.1 (the default compiler on
CenOS 5.5) crashed when compiling ost. Turns out, that
gcc doesn't like the struct in anonymous namespaces in
instantitation some of the more arcance boost.python
templates. Once the anonymous namespaces are removed
everything works.
---
 modules/base/pymod/export_logger.cc       |  4 ----
 modules/base/pymod/export_units.cc        |  6 ++----
 modules/geom/pymod/wrap_geom.cc           | 24 +++++++++++------------
 modules/info/pymod/wrap_info.cc           |  3 ---
 modules/mol/base/pymod/export_visitor.cc  |  3 ---
 modules/seq/base/pymod/export_sequence.cc |  2 --
 6 files changed, 14 insertions(+), 28 deletions(-)

diff --git a/modules/base/pymod/export_logger.cc b/modules/base/pymod/export_logger.cc
index 91baeaea0..4aa1dadc8 100644
--- a/modules/base/pymod/export_logger.cc
+++ b/modules/base/pymod/export_logger.cc
@@ -25,9 +25,6 @@ using namespace boost::python;
 
 using namespace ost;
 
-
-namespace {
-
 struct WrappedLogSink : public LogSink {
   WrappedLogSink(PyObject* self): self_(self)
   { }
@@ -88,7 +85,6 @@ void reset_sinks()
 {
   Logger::Instance().ResetSinks();
 }
-}
 
 void export_Logger()
 {
diff --git a/modules/base/pymod/export_units.cc b/modules/base/pymod/export_units.cc
index 1a50040f4..80fa61862 100644
--- a/modules/base/pymod/export_units.cc
+++ b/modules/base/pymod/export_units.cc
@@ -30,8 +30,7 @@ using namespace ost;
 
 #ifdef OST_STATIC_PROPERTY_WORKAROUND
 
-namespace {
-  struct Units_ {
+struct Units_ {
     Real get_m() { return Units::m; }
     Real get_mm() { return Units::mm; }
     Real get_nm() { return Units::nm; }
@@ -53,9 +52,8 @@ namespace {
     Real get_kDa() { return Units::kDa; }
     Real get_Da() { return Units::Da; }
     Real get_C() { return Units::C; }
-  };
+};
 
-} //ns
 
 #endif
 
diff --git a/modules/geom/pymod/wrap_geom.cc b/modules/geom/pymod/wrap_geom.cc
index e5b753e52..9c629a7cf 100644
--- a/modules/geom/pymod/wrap_geom.cc
+++ b/modules/geom/pymod/wrap_geom.cc
@@ -36,12 +36,12 @@ extern void export_Composite2_op();
 extern void export_Composite3_op();
 extern void export_Quat();
 
-namespace {
+namespace details {
 #if (defined(OST_STATIC_PROPERTY_WORKAROUND))
 struct Axis_ {
-  int X() const { return geom::Axis::X; }
-  int Y() const { return geom::Axis::Y; }
-  int Z() const { return geom::Axis::Z; }    
+  int X() { return geom::Axis::X; }
+  int Y() { return geom::Axis::Y; }
+  int Z() { return geom::Axis::Z; }    
 };
 #else
 struct Axis_ {};
@@ -67,17 +67,17 @@ BOOST_PYTHON_MODULE(_geom)
 
 #if (defined(OST_STATIC_PROPERTY_WORKAROUND))
   // workaround for a problem with boost python and python 2.6.3/4
-  object axis=class_<Axis_>("Axis_")
-   .add_property("X", &Axis_::X)
-   .add_property("Y", &Axis_::Y)
-   .add_property("Z", &Axis_::Z)
+  class_<details::Axis_> axis("Axis_");
+  axis.add_property("X", &details::Axis_::X);
+  axis.add_property("Y", &details::Axis_::Y);
+  axis.add_property("Z", &details::Axis_::Z);
  ;
  scope().attr("Axis")=axis();
 #else
-  class_<Axis_>("Axis")
-    .def_readonly("X",geom::Axis::X)
-    .def_readonly("Y",geom::Axis::Y)
-    .def_readonly("Z",geom::Axis::Z)
+  class_<details::Axis_>("Axis")
+    .def_readonly("X", geom::Axis::X)
+    .def_readonly("Y", geom::Axis::Y)
+    .def_readonly("Z", geom::Axis::Z)
   ;
 #endif
 }
diff --git a/modules/info/pymod/wrap_info.cc b/modules/info/pymod/wrap_info.cc
index 676e56f13..1b3c0ec64 100644
--- a/modules/info/pymod/wrap_info.cc
+++ b/modules/info/pymod/wrap_info.cc
@@ -34,8 +34,6 @@ using namespace boost::python;
 using namespace ost;
 using namespace ost::info;
 
-namespace {
-
 
 InfoHandle (*CreateInfoPtr1)()=CreateInfo;
 InfoHandle (*CreateInfoPtr2)(const String&)=CreateInfo;
@@ -145,7 +143,6 @@ InfoItem (InfoGroup::*create_item_b)(const String&, int)=&InfoGroup::CreateItem;
 InfoItem (InfoGroup::*create_item_c)(const String&, bool)=&InfoGroup::CreateItem;
 InfoItem (InfoGroup::*create_item_d)(const String&, Real)=&InfoGroup::CreateItem;
 
-}
 
 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(getgroup_overloads, GetGroup, 1, 2)
 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(retrievegroup_overloads, RetrieveGroup, 1, 2)
diff --git a/modules/mol/base/pymod/export_visitor.cc b/modules/mol/base/pymod/export_visitor.cc
index 0def51e95..3a6d1e328 100644
--- a/modules/mol/base/pymod/export_visitor.cc
+++ b/modules/mol/base/pymod/export_visitor.cc
@@ -23,8 +23,6 @@ using namespace boost::python;
 using namespace ost;
 using namespace ost::mol;
 
-namespace {
-
 struct WrappedVisitor : EntityVisitor
 {
     WrappedVisitor(PyObject *p)
@@ -63,7 +61,6 @@ struct WrappedVisitor : EntityVisitor
     PyObject* self;
 };
 
-}
 void export_Visitor()
 {
   class_<EntityVisitor, WrappedVisitor>("EntityVisitor", init<>())
diff --git a/modules/seq/base/pymod/export_sequence.cc b/modules/seq/base/pymod/export_sequence.cc
index bb9af670d..98677f9b8 100644
--- a/modules/seq/base/pymod/export_sequence.cc
+++ b/modules/seq/base/pymod/export_sequence.cc
@@ -38,7 +38,6 @@
 using namespace ost;
 using namespace ost::seq;
 using namespace boost::python;
-namespace {
 
 void (SequenceHandle::*attach_one)(const mol::EntityView&)=&SequenceHandle::AttachView;
 void (SequenceHandle::*attach_two)(const mol::EntityView&,
@@ -240,7 +239,6 @@ void const_seq_handle_def(O& bp_class)
   ;
 }
 
-}
 
 void export_sequence()
 {
-- 
GitLab