Проблема компиляции sigc ++ / gtkmm в собственных пространствах имен - PullRequest
1 голос
/ 14 сентября 2011

Имея собственные пространства имен в проекте, мы хотели бы включить графический интерфейс с использованием gtkmm.

// in a header file:
namespace project
{ 
    // namespace "gui" is declared elsewhere    
    class gui::Config : Gtk::Window
    {
        protected:
            Config();

        private:
            // various Gtk::Widget objects

            void connect_signals();

    };
} 

Все это работает до Я пытаюсь реализовать этот метод:

void Config::connect_signals()
{
    m_notebook.signal_switch_page().connect(sigc::mem_fun(*this,&Config::on_notebook_switch_page));
    m_button_save.signal_clicked().connect(sigc::mem_fun(*this,&Config::on_button_clicked_save));
    m_button_close.signal_clicked().connect(sigc::mem_fun(*this,&Config::on_button_clicked_close));
}

Затем мы компилируем Config.cpp, используя pkg-config --cflags gtkmm-2.4 и pkg-config --libs gtkmm-2.4.

Компилятор, наконец, выдает следующее сообщение:

In file included from /usr/include/sigc++-2.0/sigc++/signal_base.h:29:0,
         from /usr/include/sigc++-2.0/sigc++/signal.h:8,
         from /usr/include/sigc++-2.0/sigc++/sigc++.h:23,
         from /usr/include/glibmm-2.4/glibmm/signalproxy.h:13,
         from /usr/include/glibmm-2.4/glibmm/objectbase.h:23,
         from /usr/include/glibmm-2.4/glibmm/wrap.h:26,
         from /usr/include/glibmm-2.4/glibmm/containerhandle_shared.h:25,
         from /usr/include/glibmm-2.4/glibmm/arrayhandle.h:23,
         from /usr/include/glibmm-2.4/glibmm.h:83,
         from /usr/include/gtkmm-2.4/gtkmm.h:87,
         from include/libproject.h:12,
         from include/gui/Config.h:4,
         from src/gui/Config.cpp:1:
/usr/include/sigc++-2.0/sigc++/type_traits.h: In instantiation of ‘const bool sigc::is_base_and_derived<sigc::trackable, project::gui::Config>::value’:
/usr/include/sigc++-2.0/sigc++/functors/mem_fun.h:1922:26:   instantiated from ‘sigc::bound_mem_functor2<void, project::gui::Config, _GtkNotebookPage*, unsigned int>’
src/gui/Config.cpp:70:94:   instantiated from here
/usr/include/sigc++-2.0/sigc++/type_traits.h:132:16: error: ‘sigc::trackable’ is an inaccessible base of ‘project::gui::Config’
In file included from /usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:9:0,
         from /usr/include/sigc++-2.0/sigc++/functors/slot.h:7,
         from /usr/include/sigc++-2.0/sigc++/signal_base.h:31,
         from /usr/include/sigc++-2.0/sigc++/signal.h:8,
         from /usr/include/sigc++-2.0/sigc++/sigc++.h:23,
         from /usr/include/glibmm-2.4/glibmm/signalproxy.h:13,
         from /usr/include/glibmm-2.4/glibmm/objectbase.h:23,
         from /usr/include/glibmm-2.4/glibmm/wrap.h:26,
         from /usr/include/glibmm-2.4/glibmm/containerhandle_shared.h:25,
         from /usr/include/glibmm-2.4/glibmm/arrayhandle.h:23,
         from /usr/include/glibmm-2.4/glibmm.h:83,
         from /usr/include/gtkmm-2.4/gtkmm.h:87,
         from include/libproject.h:12,
         from include/gui/Config.h:4,
         from src/gui/Config.cpp:1:
/usr/include/sigc++-2.0/sigc++/functors/mem_fun.h: In instantiation of ‘sigc::bound_mem_functor2<void, project::gui::Config, _GtkNotebookPage*, unsigned int>’:
src/gui/Config.cpp:70:94:   instantiated from here
/usr/include/sigc++-2.0/sigc++/functors/mem_fun.h:1922:26: error: ‘sigc::is_base_and_derived<sigc::trackable, project::gui::Config>::value’ is not a valid template argument for type ‘bool’ because it is a non-constant expression
/usr/include/sigc++-2.0/sigc++/functors/mem_fun.h: In instantiation of ‘sigc::bound_mem_functor0<void, project::gui::Config>’:
src/gui/Config.cpp:72:95:   instantiated from here
/usr/include/sigc++-2.0/sigc++/functors/mem_fun.h:1792:26: error: ‘sigc::is_base_and_derived<sigc::trackable, project::gui::Config>::value’ is not a valid template argument for type ‘bool’ because it is a non-constant expression
/usr/include/sigc++-2.0/sigc++/functors/mem_fun.h: In constructor ‘sigc::bound_mem_functor2<T_return, T_obj, T_arg1, T_arg2>::bound_mem_functor2(T_obj&, sigc::bound_mem_functor2<T_return, T_obj, T_arg1, T_arg2>::function_type) [with T_return = void, T_obj = project::gui::Config, T_arg1 = _GtkNotebookPage*, T_arg2 = unsigned int, sigc::bound_mem_functor2<T_return, T_obj, T_arg1, T_arg2>::function_type = void (project::gui::Config::*)(_GtkNotebookPage*, unsigned int)]’:
/usr/include/sigc++-2.0/sigc++/functors/mem_fun.h:5501:77:   instantiated from ‘sigc::bound_mem_functor2<T_return, T_obj, T_arg1, T_arg2> sigc::mem_fun(T_obj&, T_return (T_obj2::*)(T_arg1, T_arg2)) [with T_arg1 = _GtkNotebookPage*, T_arg2 = unsigned int, T_return = void, T_obj = project::gui::Config, T_obj2 = project::gui::Config]’
src/gui/Config.cpp:70:94:   instantiated from here
/usr/include/sigc++-2.0/sigc++/functors/mem_fun.h:1908:18: error: using invalid field ‘sigc::bound_mem_functor2<T_return, T_obj, T_arg1, T_arg2>::obj_’
/usr/include/sigc++-2.0/sigc++/functors/mem_fun.h: In constructor ‘sigc::bound_mem_functor0<T_return, T_obj>::bound_mem_functor0(T_obj&, sigc::bound_mem_functor0<T_return, T_obj>::function_type) [with T_return = void, T_obj = project::gui::Config, sigc::bound_mem_functor0<T_return, T_obj>::function_type = void (project::gui::Config::*)()]’:
/usr/include/sigc++-2.0/sigc++/functors/mem_fun.h:5453:61:   instantiated from ‘sigc::bound_mem_functor0<T_return, T_obj> sigc::mem_fun(T_obj&, T_return (T_obj2::*)()) [with T_return = void, T_obj = project::gui::Config, T_obj2 = project::gui::Config]’
src/gui/Config.cpp:72:95:   instantiated from here
/usr/include/sigc++-2.0/sigc++/functors/mem_fun.h:1780:18: error: using invalid field ‘sigc::bound_mem_functor0<T_return, T_obj>::obj_’
/usr/include/sigc++-2.0/sigc++/functors/mem_fun.h: In function ‘void sigc::visit_each(const T_action&, const sigc::bound_mem_functor2<T_return, T_obj, T_arg1, T_arg2>&) [with T_action = sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_bind>, T_return = void, T_obj = project::gui::Config, T_arg1 = _GtkNotebookPage*, T_arg2 = unsigned int]’:
/usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:267:3:   instantiated from ‘void sigc::visit_each(const T_action&, const sigc::adaptor_functor<T_functor>&) [with T_action = sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_bind>, T_functor = sigc::bound_mem_functor2<void, project::gui::Config, _GtkNotebookPage*, unsigned int>]’
/usr/include/sigc++-2.0/sigc++/visit_each.h:170:3:   instantiated from ‘void sigc::visit_each_type(const T_action&, const T_functor&) [with T_type = sigc::trackable*, T_action = sigc::internal::slot_do_bind, T_functor = sigc::adaptor_functor<sigc::bound_mem_functor2<void, project::gui::Config, _GtkNotebookPage*, unsigned int> >]’
/usr/include/sigc++-2.0/sigc++/functors/slot.h:39:7:   instantiated from ‘sigc::internal::typed_slot_rep<T_functor>::typed_slot_rep(const T_functor&) [with T_functor = sigc::bound_mem_functor2<void, project::gui::Config, _GtkNotebookPage*, unsigned int>]’
/usr/include/sigc++-2.0/sigc++/functors/slot.h:604:65:   instantiated from ‘sigc::slot2<T_return, T_arg1, T_arg2>::slot2(const T_functor&) [with T_functor = sigc::bound_mem_functor2<void, project::gui::Config, _GtkNotebookPage*, unsigned int>, T_return = void, T_arg1 = _GtkNotebookPage*, T_arg2 = unsigned int]’
/usr/include/sigc++-2.0/sigc++/functors/slot.h:1184:26:   instantiated from ‘sigc::slot<T_return, T_arg1, T_arg2, sigc::nil, sigc::nil, sigc::nil, sigc::nil, sigc::nil>::slot(const T_functor&) [with T_functor = sigc::bound_mem_functor2<void, project::gui::Config, _GtkNotebookPage*, unsigned int>, T_return = void, T_arg1 = _GtkNotebookPage*, T_arg2 = unsigned int]’
src/gui/Config.cpp:70:95:   instantiated from here
/usr/include/sigc++-2.0/sigc++/functors/mem_fun.h:1936:3: error: ‘const class sigc::bound_mem_functor2<void, project::gui::Config, _GtkNotebookPage*, unsigned int>’ has no member named ‘obj_’
/usr/include/sigc++-2.0/sigc++/functors/mem_fun.h: In member function ‘T_return sigc::bound_mem_functor2<T_return, T_obj, T_arg1, T_arg2>::operator()(typename sigc::type_trait<T_arg3>::take, typename sigc::type_trait<T_arg4>::take) const [with T_return = void, T_obj = project::gui::Config, T_arg1 = _GtkNotebookPage*, T_arg2 = unsigned int, typename sigc::type_trait<T_arg3>::take = _GtkNotebookPage* const&, typename sigc::type_trait<T_arg4>::take = const unsigned int&]’:
/usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:103:39:   instantiated from ‘typename sigc::adaptor_functor<T_functor>::deduce_result_type<T_arg1, T_arg2>::type sigc::adaptor_functor<T_functor>::operator()(T_arg1, T_arg2) const [with T_arg1 = _GtkNotebookPage* const&, T_arg2 = const unsigned int&, T_functor = sigc::bound_mem_functor2<void, project::gui::Config, _GtkNotebookPage*, unsigned int>, typename sigc::adaptor_functor<T_functor>::deduce_result_type<T_arg1, T_arg2>::type = void]’
/usr/include/sigc++-2.0/sigc++/functors/slot.h:173:25:   instantiated from ‘static T_return sigc::internal::slot_call2<T_functor, T_return, T_arg1, T_arg2>::call_it(sigc::internal::slot_rep*, typename sigc::type_trait<T_arg3>::take, typename sigc::type_trait<T_arg4>::take) [with T_functor = sigc::bound_mem_functor2<void, project::gui::Config, _GtkNotebookPage*, unsigned int>, T_return = void, T_arg1 = _GtkNotebookPage*, T_arg2 = unsigned int, typename sigc::type_trait<T_arg3>::take = _GtkNotebookPage* const&, typename sigc::type_trait<T_arg4>::take = const unsigned int&]’
/usr/include/sigc++-2.0/sigc++/functors/slot.h:180:45:   instantiated from ‘static void* (* sigc::internal::slot_call2<T_functor, T_return, T_arg1, T_arg2>::address())(void*) [with T_functor = sigc::bound_mem_functor2<void, project::gui::Config, _GtkNotebookPage*, unsigned int>, T_return = void, T_arg1 = _GtkNotebookPage*, T_arg2 = unsigned int, void* (*)(void*) = void* (*)(void*)]’
/usr/include/sigc++-2.0/sigc++/functors/slot.h:607:7:   instantiated from ‘sigc::slot2<T_return, T_arg1, T_arg2>::slot2(const T_functor&) [with T_functor = sigc::bound_mem_functor2<void, project::gui::Config, _GtkNotebookPage*, unsigned int>, T_return = void, T_arg1 = _GtkNotebookPage*, T_arg2 = unsigned int]’
/usr/include/sigc++-2.0/sigc++/functors/slot.h:1184:26:   instantiated from ‘sigc::slot<T_return, T_arg1, T_arg2, sigc::nil, sigc::nil, sigc::nil, sigc::nil, sigc::nil>::slot(const T_functor&) [with T_functor = sigc::bound_mem_functor2<void, project::gui::Config, _GtkNotebookPage*, unsigned int>, T_return = void, T_arg1 = _GtkNotebookPage*, T_arg2 = unsigned int]’
src/gui/Config.cpp:70:95:   instantiated from here
/usr/include/sigc++-2.0/sigc++/functors/mem_fun.h:1917:61: error: using invalid field ‘sigc::bound_mem_functor2<T_return, T_obj, T_arg1, T_arg2>::obj_’
/usr/include/sigc++-2.0/sigc++/functors/mem_fun.h:1917:61: error: return-statement with a value, in function returning 'void'
/usr/include/sigc++-2.0/sigc++/functors/mem_fun.h: In function ‘void sigc::visit_each(const T_action&, const sigc::bound_mem_functor0<T_return, T_obj>&) [with T_action = sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_bind>, T_return = void, T_obj = project::gui::Config]’:
/usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:267:3:   instantiated from ‘void sigc::visit_each(const T_action&, const sigc::adaptor_functor<T_functor>&) [with T_action = sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_bind>, T_functor = sigc::bound_mem_functor0<void, project::gui::Config>]’
/usr/include/sigc++-2.0/sigc++/visit_each.h:170:3:   instantiated from ‘void sigc::visit_each_type(const T_action&, const T_functor&) [with T_type = sigc::trackable*, T_action = sigc::internal::slot_do_bind, T_functor = sigc::adaptor_functor<sigc::bound_mem_functor0<void, project::gui::Config> >]’
/usr/include/sigc++-2.0/sigc++/functors/slot.h:39:7:   instantiated from ‘sigc::internal::typed_slot_rep<T_functor>::typed_slot_rep(const T_functor&) [with T_functor = sigc::bound_mem_functor0<void, project::gui::Config>]’
/usr/include/sigc++-2.0/sigc++/functors/slot.h:451:65:   instantiated from ‘sigc::slot0<T_return>::slot0(const T_functor&) [with T_functor = sigc::bound_mem_functor0<void, project::gui::Config>, T_return = void]’
/usr/include/sigc++-2.0/sigc++/functors/slot.h:1130:26:   instantiated from ‘sigc::slot<T_return, sigc::nil, sigc::nil, sigc::nil, sigc::nil, sigc::nil, sigc::nil, sigc::nil>::slot(const T_functor&) [with T_functor = sigc::bound_mem_functor0<void, project::gui::Config>, T_return = void]’
src/gui/Config.cpp:72:96:   instantiated from here
/usr/include/sigc++-2.0/sigc++/functors/mem_fun.h:1806:3: error: ‘const class sigc::bound_mem_functor0<void, project::gui::Config>’ has no member named ‘obj_’
/usr/include/sigc++-2.0/sigc++/functors/mem_fun.h: In member function ‘T_return sigc::bound_mem_functor0<T_return, T_obj>::operator()() const [with T_return = void, T_obj = project::gui::Config]’:
/usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:251:21:   instantiated from ‘sigc::adaptor_functor<T_functor>::result_type sigc::adaptor_functor<T_functor>::operator()() const [with T_functor = sigc::bound_mem_functor0<void, project::gui::Config>, sigc::adaptor_functor<T_functor>::result_type = void]’
/usr/include/sigc++-2.0/sigc++/functors/slot.h:103:36:   instantiated from ‘static T_return sigc::internal::slot_call0<T_functor, T_return>::call_it(sigc::internal::slot_rep*) [with T_functor = sigc::bound_mem_functor0<void, project::gui::Config>, T_return = void]’
/usr/include/sigc++-2.0/sigc++/functors/slot.h:110:45:   instantiated from ‘static void* (* sigc::internal::slot_call0<T_functor, T_return>::address())(void*) [with T_functor = sigc::bound_mem_functor0<void, project::gui::Config>, T_return = void, void* (*)(void*) = void* (*)(void*)]’
/usr/include/sigc++-2.0/sigc++/functors/slot.h:454:7:   instantiated from ‘sigc::slot0<T_return>::slot0(const T_functor&) [with T_functor = sigc::bound_mem_functor0<void, project::gui::Config>, T_return = void]’
/usr/include/sigc++-2.0/sigc++/functors/slot.h:1130:26:   instantiated from ‘sigc::slot<T_return, sigc::nil, sigc::nil, sigc::nil, sigc::nil, sigc::nil, sigc::nil, sigc::nil>::slot(const T_functor&) [with T_functor = sigc::bound_mem_functor0<void, project::gui::Config>, T_return = void]’
src/gui/Config.cpp:72:96:   instantiated from here
/usr/include/sigc++-2.0/sigc++/functors/mem_fun.h:1787:49: error: using invalid field ‘sigc::bound_mem_functor0<T_return, T_obj>::obj_’
/usr/include/sigc++-2.0/sigc++/functors/mem_fun.h:1787:49: error: return-statement with a value, in function returning 'void'
/usr/include/sigc++-2.0/sigc++/functors/mem_fun.h: In function ‘void sigc::visit_each(const T_action&, const sigc::bound_mem_functor2<T_return, T_obj, T_arg1, T_arg2>&) [with T_action = sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_unbind>, T_return = void, T_obj = project::gui::Config, T_arg1 = _GtkNotebookPage*, T_arg2 = unsigned int]’:
/usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:267:3:   instantiated from ‘void sigc::visit_each(const T_action&, const sigc::adaptor_functor<T_functor>&) [with T_action = sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_unbind>, T_functor = sigc::bound_mem_functor2<void, project::gui::Config, _GtkNotebookPage*, unsigned int>]’
/usr/include/sigc++-2.0/sigc++/visit_each.h:170:3:   instantiated from ‘void sigc::visit_each_type(const T_action&, const T_functor&) [with T_type = sigc::trackable*, T_action = sigc::internal::slot_do_unbind, T_functor = sigc::adaptor_functor<sigc::bound_mem_functor2<void, project::gui::Config, _GtkNotebookPage*, unsigned int> >]’
/usr/include/sigc++-2.0/sigc++/functors/slot.h:60:7:   instantiated from ‘static void* sigc::internal::typed_slot_rep<T_functor>::destroy(void*) [with T_functor = sigc::bound_mem_functor2<void, project::gui::Config, _GtkNotebookPage*, unsigned int>]’
/usr/include/sigc++-2.0/sigc++/functors/slot.h:38:52:   instantiated from ‘sigc::internal::typed_slot_rep<T_functor>::typed_slot_rep(const T_functor&) [with T_functor = sigc::bound_mem_functor2<void, project::gui::Config, _GtkNotebookPage*, unsigned int>]’
/usr/include/sigc++-2.0/sigc++/functors/slot.h:604:65:   instantiated from ‘sigc::slot2<T_return, T_arg1, T_arg2>::slot2(const T_functor&) [with T_functor = sigc::bound_mem_functor2<void, project::gui::Config, _GtkNotebookPage*, unsigned int>, T_return = void, T_arg1 = _GtkNotebookPage*, T_arg2 = unsigned int]’
/usr/include/sigc++-2.0/sigc++/functors/slot.h:1184:26:   instantiated from ‘sigc::slot<T_return, T_arg1, T_arg2, sigc::nil, sigc::nil, sigc::nil, sigc::nil, sigc::nil>::slot(const T_functor&) [with T_functor = sigc::bound_mem_functor2<void, project::gui::Config, _GtkNotebookPage*, unsigned int>, T_return = void, T_arg1 = _GtkNotebookPage*, T_arg2 = unsigned int]’
src/gui/Config.cpp:70:95:   instantiated from here
/usr/include/sigc++-2.0/sigc++/functors/mem_fun.h:1936:3: error: ‘const class sigc::bound_mem_functor2<void, project::gui::Config, _GtkNotebookPage*, unsigned int>’ has no member named ‘obj_’
/usr/include/sigc++-2.0/sigc++/functors/mem_fun.h: In function ‘void sigc::visit_each(const T_action&, const sigc::bound_mem_functor0<T_return, T_obj>&) [with T_action = sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_unbind>, T_return = void, T_obj = project::gui::Config]’:
/usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:267:3:   instantiated from ‘void sigc::visit_each(const T_action&, const sigc::adaptor_functor<T_functor>&) [with T_action = sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_unbind>, T_functor = sigc::bound_mem_functor0<void, project::gui::Config>]’
/usr/include/sigc++-2.0/sigc++/visit_each.h:170:3:   instantiated from ‘void sigc::visit_each_type(const T_action&, const T_functor&) [with T_type = sigc::trackable*, T_action = sigc::internal::slot_do_unbind, T_functor = sigc::adaptor_functor<sigc::bound_mem_functor0<void, project::gui::Config> >]’
/usr/include/sigc++-2.0/sigc++/functors/slot.h:60:7:   instantiated from ‘static void* sigc::internal::typed_slot_rep<T_functor>::destroy(void*) [with T_functor = sigc::bound_mem_functor0<void, project::gui::Config>]’
/usr/include/sigc++-2.0/sigc++/functors/slot.h:38:52:   instantiated from ‘sigc::internal::typed_slot_rep<T_functor>::typed_slot_rep(const T_functor&) [with T_functor = sigc::bound_mem_functor0<void, project::gui::Config>]’
/usr/include/sigc++-2.0/sigc++/functors/slot.h:451:65:   instantiated from ‘sigc::slot0<T_return>::slot0(const T_functor&) [with T_functor = sigc::bound_mem_functor0<void, project::gui::Config>, T_return = void]’
/usr/include/sigc++-2.0/sigc++/functors/slot.h:1130:26:   instantiated from ‘sigc::slot<T_return, sigc::nil, sigc::nil, sigc::nil, sigc::nil, sigc::nil, sigc::nil, sigc::nil>::slot(const T_functor&) [with T_functor = sigc::bound_mem_functor0<void, project::gui::Config>, T_return = void]’
src/gui/Config.cpp:72:96:   instantiated from here
/usr/include/sigc++-2.0/sigc++/functors/mem_fun.h:1806:3: error: ‘const class sigc::bound_mem_functor0<void, project::gui::Config>’ has no member named ‘obj_’
make: *** [src/gui/Config.o] Error 1

Мы не увереныесли проблема действительно связана с библиотекой sigc ++ или это просто проблема пространства имен.Когда мы скомпилировали тот же файл без пространств имен в отдельном файле, это сработало.

Любая идея приветствуется, С уважением

Ответы [ 2 ]

2 голосов
/ 14 сентября 2011

Ваш класс находится в частном порядке от Gtk::Window

class gui::Config : Gtk::Window

против

class gui::Config : public Gtk::Window

Похоже, сигналы пытаются подключиться к этим интерфейсам, но они недоступны.

0 голосов
/ 14 сентября 2011

Вам необходимо импортировать все три пространства имен в файл, где предоставляются определения.

using namespace project;
using namespace gui;
using namespace gtk;

void Config::connect_signals()
{
   // ...
}

Но я вижу, project, gui пространства имен избыточны.Уже Config находится в пространстве имен project.Я не понимаю ваш комментарий о том, что gui пространство имен объявлено еще где.Этого будет достаточно -

namespace project
{ 
    class Config : Gtk::Window  // The class being inherited is from a different namespace
    {
         //...
...