代码之家  ›  专栏  ›  技术社区  ›  nmichaels

编译ncurses时出错

  •  0
  • nmichaels  · 技术社区  · 7 年前

    我正在尝试为嵌入式系统编译ncurses 5.9(使用buildroot),我收到了以下错误消息:

    In file included from ../c++/cursesm.h:39:0,
                     from ../c++/cursesm.cc:35:
    ../c++/cursesp.h: In member function ‘T* NCursesUserPanel<T>::UserData() const’:
    ../c++/cursesp.h:256:43: error: no matching function for call to 
    ‘NCursesUserPanel<T>::get_user() const’
         return reinterpret_cast<T*>(get_user ());
    

    /* We use templates to provide a typesafe mechanism to associate
     * user data with a panel. A NCursesUserPanel<T> is a panel
     * associated with some user data of type T.
     */
    template<class T> class NCursesUserPanel : public NCursesPanel
    {
    public:
      NCursesUserPanel (int nlines,
                        int ncols,
                        int begin_y = 0,
                        int begin_x = 0,
                        const T* p_UserData = STATIC_CAST(T*)(0))
        : NCursesPanel (nlines, ncols, begin_y, begin_x)
      {
          if (p)
            set_user (const_cast<void *>(p_UserData));
      };
      // This creates an user panel of the requested size with associated
      // user data pointed to by p_UserData.
    
      NCursesUserPanel(const T* p_UserData = STATIC_CAST(T*)(0)) : NCursesPanel()
      {
        if (p)
          set_user(const_cast<void *>(p_UserData));
      };
      // This creates an user panel associated with the ::stdscr and user data
      // pointed to by p_UserData.
    
      virtual ~NCursesUserPanel() {};
    
      T* UserData (void) const
      {
        return reinterpret_cast<T*>(get_user ());
      };
      // Retrieve the user data associated with the panel.
    
      virtual void setUserData (const T* p_UserData)
      {
        if (p)
          set_user (const_cast<void *>(p_UserData));
      }
      // Associate the user panel with the user data pointed to by p_UserData.
    };
    

    第256行是这样的: return reinterpret_cast<T*>(get_user ());

    1 回复  |  直到 7 年前
        1
  •  3
  •   nmichaels    7 年前

    这里的问题是由于编译器更新到 g++ (Debian 7.2.0-5) . 新的编译器具有更好的错误处理能力,而这段旧代码编写时没有其优点。这里的解决方案是要么使用最新版本的ncurses(不适合我的特殊情况),要么使用较旧的编译器。因为我的主机系统是Debian,所以我使用了 update-alternatives

    我把这个留在这里是因为谷歌没有给我提供关于错误消息的好结果。