Reputation: 11431
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 directive
#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.
- Why i am getting these warnings and from C++ standard point of view?
- What is the good reason why compiler is warning for this?
- What is the best way to fix this?
Thanks
Upvotes: 31
Views: 63397
Reputation: 75
In C++:
#ifndef YOUR_DEFINE
#define YOUR_DEFINE
// your code here
#endif // YOUR_DEFINE
Upvotes: 0
Reputation: 16266
#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.
Upvotes: 46
Reputation: 258608
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
Upvotes: 18
Reputation: 19790
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
Upvotes: 0
Reputation: 34625
#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.
Upvotes: 0