1

プロジェクトに独自の名前空間があるので、gtkmmを使用してGUIを含めたいと思います。

// 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));
}

pkg-config --cflags gtkmm-2.4次に、とを使用してConfig.cppをコンパイルし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++に関連しているのか、それとも単なる名前空間の問題なのかはわかりません。名前空間なしで同じファイルを別のファイルにコンパイルすると、機能しました。

よろしくお願いします。

4

2 に答える 2

2

あなたのクラスは私的にから継承していますGtk::Window

class gui::Config : Gtk::Window

vs

class gui::Config : public Gtk::Window

信号がこれらのインターフェイスに接続しようとしているように見えますが、アクセスできません。

于 2011-09-14T14:37:12.810 に答える
0

3つの名前空間すべてを、定義が提供されているファイルにインポートする必要があります。

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

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

しかし、project, gui名前空間は冗長だと思います。すでにConfig名前空間にありますprojectgui名前空間が他の場所で宣言されているというあなたのコメントがわかりません。これで十分です-

namespace project
{ 
    class Config : Gtk::Window  // The class being inherited is from a different namespace
    {
         //...
于 2011-09-14T14:37:46.167 に答える