www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - Preprocessor error: '#endif' found without '#if'

↑ ↓ ← SL <shadowlord13 gmail.com> writes:
I've got a bit of a request. Whenever I have an #endif somewhere with no 
matching #if/#ifdef, DMC gives an error like this:
#endif
      ^
tdpolygs.h(2700) : Preprocessor error: '#endif' found without '#if'

Line 2698-2700:
#else
#include "polygs2.h"
#endif

Before those there's an #ifndef OLDPOLY3D line, and lots of code which 
gets skipped because I'm working on the function in another (temporary) 
file - polygs2.h.

The actual cause of the error is that on line 150 of polygs2.h, I have 
an #endif which I missed when I deleted its #ifdef and #else.

The problem is, it'd be pretty hard to track down that #endif with just 
what DMC tells me. Luckily, since I've ported this DOS program to 
windows without forking the source, I can tell BC 3.1 to compile it for 
DOS, and it'll hit the same problem. Why would I do that? Because BC 3.1 
gives this error message instead:

Error polygs2.h 150: Misplaced endif directive in function poly3d(float 
*,float
*,float *,unsigned int,unsigned char)

Which is exactly where I need to go to find that errant #endif.

I'd love to see DMC do like BC 3.1 and give the line number of the 
actual cause. But I have a feeling this wouldn't be easy to implement.

-SL
Jun 08 2005
↑ ↓ → "Matthew" <admin stlsoft.dot.dot.dot.dot.org> writes:
Seconded

"SL" <shadowlord13 gmail.com> wrote in message 
news:d87urk$2t7j$1 digitaldaemon.com...
 I've got a bit of a request. Whenever I have an #endif somewhere 
 with no matching #if/#ifdef, DMC gives an error like this:
 #endif
      ^
 tdpolygs.h(2700) : Preprocessor error: '#endif' found without 
 '#if'

 Line 2698-2700:
 #else
 #include "polygs2.h"
 #endif

 Before those there's an #ifndef OLDPOLY3D line, and lots of code 
 which gets skipped because I'm working on the function in another 
 (temporary) file - polygs2.h.

 The actual cause of the error is that on line 150 of polygs2.h, I 
 have an #endif which I missed when I deleted its #ifdef and #else.

 The problem is, it'd be pretty hard to track down that #endif with 
 just what DMC tells me. Luckily, since I've ported this DOS 
 program to windows without forking the source, I can tell BC 3.1 
 to compile it for DOS, and it'll hit the same problem. Why would I 
 do that? Because BC 3.1 gives this error message instead:

 Error polygs2.h 150: Misplaced endif directive in function 
 poly3d(float *,float
 *,float *,unsigned int,unsigned char)

 Which is exactly where I need to go to find that errant #endif.

 I'd love to see DMC do like BC 3.1 and give the line number of the 
 actual cause. But I have a feeling this wouldn't be easy to 
 implement.

 -SL 

Jun 13 2005