Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

warning: extra tokens at end of #endif directive

Tags:

c++

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.

  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

like image 624
venkysmarty Avatar asked Sep 19 '11 07:09

venkysmarty


2 Answers

should be:

#endif // USE_IOSTREAM
#endif // WIN32

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

EDIT:

and you miss closing #endif // _OM_NO_IOSTREAM at the end

like image 146
Andriy Tylychko Avatar answered Nov 15 '22 23:11

Andriy Tylychko


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
like image 18
Luchian Grigore Avatar answered Nov 16 '22 00:11

Luchian Grigore