[C++-sig] Compile error when using exception_translation.hpp

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Tue Oct 13 18:51:29 CEST 2009


translate_exception.hpp is in the "detail" directory.
The convention is that this isn't a public interface.
#include <boost/python/exception_translator.hpp>
fixes your problem (at least under Fedora 8).
Ralf



----- Original Message ----
From: Ger van Diepen <diepen at astron.nl>
To: boost-users at lists.boost.org; cplusplus-sig at python.org
Sent: Mon, October 12, 2009 12:38:42 AM
Subject: [C++-sig] Compile error when using exception_translation.hpp

When compiling the following code using gcc-4.3.2 and boost-1.37, I get
errors as listed at the end. It also fails for boost-1.40 and gcc-4.3.4.

It is solved when patching translate_exception.hpp by adding
# include <boost/type_traits/add_reference.hpp>

Is it a Boost-Python problem or do I do something wrong?
Of course, I can include that file in my own code, but that does not
seem the correct solution to me.

Thanks,
Ger van Diepen


  #include <boost/translate_exception.hpp>
  #include <stdexcept>
  void translate_stdexcp (const std::exception& e)
  {
    PyErr_SetString(PyExc_RuntimeError, e.what());
  }

  //# Note that the most general exception must be registered first.
  void register_convert_excp()
  {
    boost::python::register_exception_translator<std::exception>
      (&translate_stdexcp);
  }


/home/jds/Work/svn-usg/release/include/boost/python/detail/translate_exception.hpp:34:
error: expected nested-name-specifier before ‘add_reference’
/home/jds/Work/svn-usg/release/include/boost/python/detail/translate_exception.hpp:34:
error: expected ‘;’ before ‘<’ token
/home/jds/Work/svn-usg/release/include/boost/python/detail/translate_exception.hpp:
In member function ‘bool
boost::python::detail::translate_exception<ExceptionType,
Translate>::operator()(const
boost::python::detail::exception_handler&,
const boost::function0<void>&, typename
boost::call_traits<Translate>::param_type) const’:
/home/jds/Work/svn-usg/release/include/boost/python/detail/translate_exception.hpp:56:
error: expected type-specifier before ‘exception_cref’
/home/jds/Work/svn-usg/release/include/boost/python/detail/translate_exception.hpp:56:
error: expected `)' before ‘e’
/home/jds/Work/svn-usg/release/include/boost/python/detail/translate_exception.hpp:56:
error: expected `{' before ‘e’
/home/jds/Work/svn-usg/release/include/boost/python/detail/translate_exception.hpp:56:
error: ‘e’ was not declared in this scope
/home/jds/Work/svn-usg/release/include/boost/python/detail/translate_exception.hpp:56:
error: expected `;' before ‘)’ token

_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig at python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


More information about the Cplusplus-sig mailing list