Strange error with a bool

this has got to be a stupid mistake im making, please help!

A line in my project:
 
bool running = true;


my error:
1
2
3
4
5
F:\OpenGl\BitMaps_OpenGL\main.cpp|11|error: two or more data types in declaration of 'running'|
F:\OpenGl\BitMaps_OpenGL\main.cpp||In function 'int WinMain(HINSTANCE__*, HINSTANCE__*, CHAR*, int)':|
F:\OpenGl\BitMaps_OpenGL\main.cpp|175|error: 'running' was not declared in this scope|
||=== Build finished: 2 errors, 0 warnings ===|


my loop on line 175:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
while(running)
    {
        g_glRender->Prepare(0.0);
        g_glRender->Render();
        SwapBuffers(hDC);

        while(PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
        {
            if(!GetMessage(&msg, NULL, 0, 0))
            {
                running = false;
                break;
            }

            TranslateMessage(&msg);
            DispatchMessage(&msg);

        }
    }
Your entire code?

There is clearly a variable called running somewhere before line 11 in main.cpp (which I presume is the line you just posted) but the question is, where else did you creating the running variable?

Also, it seems like running has left the scope by the time it gets to line 175.

A quick fix (albeit wrong) is to just change the name so you don't violate the one declaration rule (I suppose it applies to variables as well).
so i messed around a little, and im getting an even stranger error, if i move the bool down to the bottom of the declaration list it now says the next variable has two or more data types. The program is roughly 200 lines+ so i dont want to post the entire thing

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#define WIN32_LEAN_AND_MEAN
#define WIN32_EXTRA_LEAN

#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <iostream>
#include "CGfxOpenGL.h"

long windowWidth = 1024;
long windowHeight = 768;
long windowBits = 32;
bool running = true;
HDC hDC;


The error now coresponds to windowwidth, any ideas?
My guess is that there is a running variable in one of the headers some where, as VP said what happens when you rename it?
Either you are compiling your code as a C-code or there is some error in a header.
Last edited on
maybe running is already defined as a macro (#define ) somewhere in the headers
There is either an error in the "gl" headers, or "CGfxOpenGL.h". I'm learning towards the last one because it looks like there could be errors in it. Possibly post that?

If it's a third party header, it's possible the library needs reinstalled. If it's your header, I believe that's all that's wrong.
problem solved, it was as simple as forgetting a colon after my class in the header file. Thanks for all the help!
If it works it works, but I've also found that many std libraries (iostream) need to be included before gl libraries.

@Others, glu.h and gl.h are the header files for OpenGL, so I would hope there's nothing wrong with them :)
Topic archived. No new replies allowed.