警告:#endif指令末尾的额外令牌

ven*_*rty 20 c++

我正在使用VxWorks6.8 C++编译器编译一个相当大的项目.我收到了警告

警告:#endif指令末尾的额外令牌

#ifndef _OM_NO_IOSTREAM
#ifdef WIN32
#ifndef USE_IOSTREAM
#define USE_IOSTREAM
#endif USE_IOSTREAM
#endif WIN32
Run Code Online (Sandbox Code Playgroud)

我收到了很多这些警告.

  1. 为什么我从C++标准的角度来看这些警告?
  2. 编译器为此提出警告的理由是什么?
  3. 解决这个问题的最佳方法是什么?

谢谢

And*_*hko 36

应该:

#endif // USE_IOSTREAM
#endif // WIN32
Run Code Online (Sandbox Code Playgroud)

endif没有任何争论.此类评论仅用于提高可读性

编辑:

而你错过了最后#endif // _OM_NO_IOSTREAM的结束


Luc*_*ore 15

因为你以后什么都没有 #endif

而且,你错过了一个endif.

#ifndef _OM_NO_IOSTREAM
  #ifdef WIN32
    #ifndef USE_IOSTREAM
      #define USE_IOSTREAM
    #endif
  #endif
#endif
Run Code Online (Sandbox Code Playgroud)