Preprocessor OpenGL c++ issue

Pages: 12

EDIT: I HAVE UPLOADED A VIDEO SHOWING THE PROBLEM

https://youtu.be/uWlSUxxMy08
AND
https://youtu.be/iUW3Z2u3IDs

UPDATED ENTIRE RELATED FILES: https://drive.google.com/file/d/1ExZFWoK1ExZtHh06GcGuKX9hLk5gMqUG/view?usp=sharing


I am using vs 6.0 with OpenGL.

Im having preprocessor problems. I have a class called planet. I have created several other objects using base class planets such as "Earth.h". But now I create a new one called "Mars.h" I have errors that I did not encounter before when I created Earth.h.

I added in two #includes to eliminate the errors that are obviously related to objects I created in other files but all it does is reduce the number of errors. The latest errors are OpenGL related errors that I cannot fix because it would be editing OpenGL related .h files.

c:\...\VC98\include\GL\GL.H
WINGDIAPI void APIENTRY glClearDepth (GLclampd depth);
WINGDIAPI void APIENTRY glClearIndex (GLfloat c);<<------ERROR ARROW
WINGDIAPI void APIENTRY glClearStencil (GLint s);

c:\program files (x86)\microsoft visual studio\vc98\include\gl\gl.h(1166) : error C2143: syntax error : missing ')' before 'constant'
Last edited on
You should probably be looking inside header files you created before thinking there is anything wrong with the headers that come with your compiler.

> But now I create a new one called "Mars.h" I have errors that I did not encounter before when I created Earth.h.
Yeah, study what you did in both of those.

Missing ; are a good thing to look for.
Since the error message refers to a missing ), maybe you're missing one in your header file.


Another thing to do is increase the frequency you press "compile" between edit sessions.
If you write 5 lines in one file and press compile, then find there is a problem, you have a damn good idea where to look.

If you change 100's of lines in multiple files over half a day, then press compile only to find a load of errors, then you're clueless as to where to start looking.

Never write more code than you're prepared for the compiler to say "nope" to.

The same goes for testing, make sure your new code works before creating more code.
There's no point coding for days and then wondering why it doesn't work.
You should probably be looking inside header files you created before thinking there is anything wrong with the headers that come with your compiler.

I DID, the new one Mars.H is only a couple lines and I included it in my post so you can see how simple and small it is unlikely to cause any problems yet it does.

Missing ; are a good thing to look for.
Since the error message refers to a missing ), maybe you're missing one in your header file.

Nope, because whenever I remove reference to Planet.H and remove the :planet to remove the fact that Mars is inheriting Planet it works again. No ; issues. The ; issues according to complier is in the GL related code.

Another thing to do is increase the frequency you press "compile" between edit sessions.
If you write 5 lines in one file and press compile, then find there is a problem, you have a damn good idea where to look.

I did nothing but hit F5 every line. Found nothing interesting.

If you change 100's of lines in multiple files over half a day, then press compile only to find a load of errors, then you're clueless as to where to start looking.

Never write more code than you're prepared for the compiler to say "nope" to.

Ofcourse not.

The same goes for testing, make sure your new code works before creating more code.
There's no point coding for days and then wondering why it doesn't work.

Yeah.... thanks for responding but nothing you said was of any use. A for effort!
Well sure, how about posting YOUR code and not a 1-line error message in a system header file.

You're the waste of time.
Nothing you said was of any use to me but have a look at this new video:

https://youtu.be/uWlSUxxMy08

AND

https://youtu.be/iUW3Z2u3IDs
Last edited on
2nd video posted

https://youtu.be/iUW3Z2u3IDs
Right, and what's in planet.h?

Megabytes of video to represent at best a kilobyte of information isn't good bandwidth use.

Start with a new empty project with the minimal header files necessary to produce the problem.
http://www.sscce.org/
Told you it is a hard problem and not an obvious error on my part ;)
First thing first, why the heck are you using VS 6.0? It's ancient. A newer compiler would probably give you a saner error message.

The latest errors are OpenGL related errors that I cannot fix because it would be editing OpenGL related .h files.

c:\...\VC98\include\GL\GL.H
WINGDIAPI void APIENTRY glClearDepth (GLclampd depth);
WINGDIAPI void APIENTRY glClearIndex (GLfloat c);<<------ERROR ARROW
WINGDIAPI void APIENTRY glClearStencil (GLint s);
I have seen this weird errors like this happen when you forget a semicolon after or before an OpenGL call. (For example, GLAD or GLEW use weird #define methods to declare OpenGL API functions beyond version 1. Maybe VS is doing something similar with those entries.)

I see from the video that in SoundParticle.h, you have at least one superfluous (albeit, harmless) semicolon after your SoundParticle constructor.

You're probably missing a ) or ; somewhere in a header. I suggest carefully scanning through your code and reading it out loud to yourself as you go.

There's an extra semi-colon in ./Sun.h: glTranslated(0,offSet,0);; but that's probably harmless.

PS:
double Avo = 602214085774*10^12;
That is not correct.
Last edited on
I'm outa here.
1
2
3
4
5
6
7
8
9
10
11
$ g++ -c Mars.cpp 
In file included from SoundWave.h:1,
                 from SoundWaveList.h:7,
                 from Atmosphere.h:4,
                 from Planet.h:6,
                 from Mars.h:5,
                 from Mars.cpp:5:
SoundParticle.h:5:10: fatal error: coordinates.h: No such file or directory
    5 | #include "coordinates.h"
      |          ^~~~~~~~~~~~~~~
compilation terminated.


I'm simply not going to play 20 questions with an OP that can't be bothered to make something testable.


http://www.sscce.org/
Read it!
Make a clone project, comment out everything irrelevant to the problem until the problem goes away.
Then study your last change and add things back in again slowly.

And as Ganado points out, the compiler was used by the Druids to design Stonehenge.
I'm just doing this because I like the puzzle, not because OP is being nice or anything.

Planet.h doesn't end in a newline. (Idk if this is *the* problem, but it might be a contributing factor.)
Last edited on
I am using vs 6.0 with OpenGL.

Spock wasn't able to make a mnemonic memory circuit using stone knives and bear skins, using VS 6.0 in the 21st Century is even more primitive.

MS has Visual Studio 2022 in a FREE Community edition. Dump the 1990's IDE.
Planet.h doesn't end in a newline.

is that still enforced by anything? It used to be needed for unix tools for some weird reason, but they seem to have gotten over it?
Can you upload the complete project - without Degug/Release folder of course.
>Planet.h doesn't end in a newline.
is that still enforced by anything? It used to be needed for unix tools for some weird reason, but they seem to have gotten over it?
Separate issue from unix tools. I don't remember exactly, but I think the problem is that when the copy-paste from #include happens, the #endif will potentially be on the same line as other code. This is NOT a problem in later versions of the standard (definitely C++11, idk about before), but VS6 is old as crap so it might be causing a problem. I don't know for sure.
ENTIRE CODE HERE:

https://drive.google.com/file/d/1ExZFWoK1ExZtHh06GcGuKX9hLk5gMqUG/view?usp=sharing


THANKS ALL IN ADVANCE!! IF yOU CAN UPGRADE IT TO VS 11 that will be great too!

I HAVE GUTTED IT SO THAT IN THE BEGINING WHEN YOU PRESS F5 it will compile and run correctly and close it self. When you comment in the INCLUDE PLANET and the : Planet in Mar.H that will reproduce the errors.

David
Last edited on
I tried to compile with VS2010 and got the following errors:

\darkdave\world.h(2): fatal error C1083: Cannot open include file: 'fstream.h': No such file or directory
1>  Textout.cpp
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdlib.h(353): 
error C2381: 'exit' : redefinition; __declspec(noreturn) differs
1>          c:\users\thomas\desktop\darkdave\gl\glut.h(146) : see declaration of 'exit'
\darkdave\gamerenderer.h(554): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(554): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(554): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(556): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(556): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(707): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(707): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(707): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(709): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(709): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(734): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(734): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(734): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(736): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(736): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(759): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(759): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(759): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(761): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(761): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(783): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(783): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(783): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(785): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(785): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(807): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(807): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(807): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(809): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(809): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(831): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(831): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(831): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(833): error C2065: 'i' : undeclared identifier
\darkdave\gamerenderer.h(833): error C2065: 'i' : undeclared identifier
\darkdave\textout.h(494): warning C4018: '>' : signed/unsigned mismatch
\darkdave\textout.cpp(73): warning C4018: '>' : signed/unsigned mismatch
\darkdave\textout.cpp(214): warning C4018: '<' : signed/unsigned mismatch
\darkdave\textout.cpp(227): warning C4018: '<' : signed/unsigned mismatch
\darkdave\textout.cpp(243): warning C4018: '<' : signed/unsigned mismatch
\darkdave\textout.cpp(260): warning C4018: '<' : signed/unsigned mismatch
\darkdave\textout.cpp(274): warning C4018: '<' : signed/unsigned mismatch
\darkdave\textout.cpp(326): warning C4018: '<' : signed/unsigned mismatch
1>  StarShip.cpp
\darkdave\bmp.h(12): fatal error C1083: Cannot open include file: 'gl\glaux.h': No such file or directory
1>  SpaceCraft.cpp
\darkdave\bmp.h(12): fatal error C1083: Cannot open include file: 'gl\glaux.h': No such file or directory
1>  Object.cpp
\darkdave\bmp.h(12): fatal error C1083: Cannot open include file: 'gl\glaux.h': No such file or directory
1>  Mars.cpp
1>  Main.cpp
\darkdave\world.h(2): fatal error C1083: Cannot open include file: 'fstream.h': No such file or directory
1>  LEM.cpp
\darkdave\bmp.h(12): fatal error C1083: Cannot open include file: 'gl\glaux.h': No such file or directory
1>  Clock.cpp
\darkdave\clock.h(9): fatal error C1083: Cannot open include file: 'fstream.h': No such file or directory
1>  bomb.cpp
\darkdave\bmp.h(12): fatal error C1083: Cannot open include file: 'gl\glaux.h': No such file or directory
1>  Airship.cpp
\darkdave\bmp.h(12): fatal error C1083: Cannot open include file: 'gl\glaux.h': No such file or directory


Most of them would be easy to fix.
The file gl\glaux.h is missing
#include <fstream.h> should be #include <fstream>

c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdlib.h(353): error C2381: 'exit' : redefinition; __declspec(noreturn) differs

see: https://social.msdn.microsoft.com/Forums/en-US/4cf463c1-5fee-4daa-b135-be8b06ab7f8f/error-c2381-exit-redefinition-declspecnoreturn-differs
Did it work when you experimented with these solutions?
Not yet. The biggest problem is the missing gl\glaux.h
Can you upload it ?
Pages: 12