开发者

warning: extra tokens at end of #endif directive

I am compiling a quite a big project using VxWorks6.8 C++ compiler. I am getting following warning

warning: extra tokens at end of #endif direc开发者_高级运维tive

#ifndef _OM_NO_IOSTREAM
#ifdef WIN32
#ifndef USE_IOSTREAM
#define USE_IOSTREAM
#endif USE_IOSTREAM
#endif WIN32

I am getting a quite a lot of these warnings.

  1. Why i am getting these warnings and from C++ standard point of view?
  2. What is the good reason why compiler is warning for this?
  3. What is the best way to fix this?

Thanks


#endif USE_IOSTREAM
#endif WIN32

Should be:

#endif // USE_IOSTREAM
#endif // WIN32

endif doesn't take any arguments. Such comments are placed only for better readability.

You also missed closing #endif // _OM_NO_IOSTREAM at the end.


Because you can't have anything after #endif

Also, you're missing an endif.

#ifndef _OM_NO_IOSTREAM
  #ifdef WIN32
    #ifndef USE_IOSTREAM
      #define USE_IOSTREAM
    #endif
  #endif
#endif


#endif USE_IOSTREAM
#endif WIN32
    // ^^^^^^^^^^^^ Compiler is warning about these extra tokens after endif directive.

There is no need of any identifier after #endif. The way to suppress those warnings is to remove them.


Normally you don't put text behind the #endif. (And you are missing an #endif for OM_NO_IOSTREAM)

http://msdn.microsoft.com/en-us/library/ew2hz0yd%28v=vs.80%29.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜