结构的前向声明 - 编译错误,"匿名结构的声明必须是一个定义"

时间:2017-06-06 04:44:53

标签: c++ anonymous-types forward-declaration libsigc++

我正在编译使用sigc++的应用程序。它失败并出现此错误:

In file included from /opt/local/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:7:
/opt/local/include/sigc++-2.0/sigc++/functors/functor_trait.h:17:1: error: declaration of anonymous struct must be a definition
struct nil;

有问题的代码是:

              namespace sigc {

              /** nil struct type.
               * The nil struct type is used as default template argument in the
               * unnumbered sigc::signal and sigc::slot templates.
               *
               * @ingroup signal
               * @ingroup slot
               */
              #ifndef DOXYGEN_SHOULD_SKIP_THIS
error here -> struct nil;
              #else
              struct nil {};
              #endif

我无法弄清楚,为什么编译器认为它是一个匿名结构。这条线不仅仅是一个前瞻性声明吗?

0 个答案:

没有答案