编译ncurses时出错

nmi*_*els 0 ncurses embedded-linux

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

\n\n
In file included from ../c++/cursesm.h:39:0,\n                 from ../c++/cursesm.cc:35:\n../c++/cursesp.h: In member function \xe2\x80\x98T* NCursesUserPanel<T>::UserData() const\xe2\x80\x99:\n../c++/cursesp.h:256:43: error: no matching function for call to \n\xe2\x80\x98NCursesUserPanel<T>::get_user() const\xe2\x80\x99\n     return reinterpret_cast<T*>(get_user ());\n
Run Code Online (Sandbox Code Playgroud)\n\n

这是有问题的代码:

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

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

\n

nmi*_*els 5

这里的问题是由于编译器更新为g++ (Debian 7.2.0-5). 新的编译器具有更好的错误处理能力,而旧代码的编写并没有带来任何好处。这里的解决方案是使用更新版本的 ncurses(不适用于我的特定情况)或使用较旧的编译器。由于我的主机系统是 Debian,我使用update-alternatives切换到 g++ 6.4,有问题的错误消息消失了。

我将其留在这里是因为 Google 没有为该错误消息提供良好的结果。