PDA

View Full Version : VC++ problem



02-26-2003, 12:36 PM
Hello!
I wonder if you could help me in my problem. I'm getting some errors while compiling OGL program and I have no idea where do they come from. I've tried everything and still it didn't bring any results. I have a source file and a header file. I wanted to put all includes and globals into the header but i get the same erros. It look like that :

// main.h

#include <windows.h>
#include <math.h>
#include <stdio.h>
#include <gl\gl.h>
#include <gl\glu.h>
#include <gl\glaux.h>
#include <iostream.h>

#pragma comment(lib, "Winmm.lib")
#pragma comment(lib, "OpenGL32.lib")
#pragma comment(lib, "Glu32.lib")

extern HWND hWnd = NULL;
extern HINSTANCE hInstance = NULL;
extern HDC hDc = NULL;
extern HRC hRc = NULL;

main.h(37) : error C2146: syntax error : missing ';' before identifier 'hRc'
main.h(37) : fatal error C1004: unexpected end of file found

Let me know if you find anything! I would really appreciate any help.

Thanks

yaro_dup1
02-26-2003, 12:49 PM
Hi,

I think You shouldn't declare extern variables with setting the value to them in *.h file. You should declare them in some *.cpp file.
For example:

// main.h
extern HDC hDC;
extern HRC hRC;

// main.cpp
HDC hDC;
HRC hRC;

cheers
yaro

Armageddon
02-26-2003, 02:22 PM
I think you'll find it should be HGLRC not HRC.

glYaro is also correct, you shouldn't try to initialise variables when they're externed, you should initialise them where their main instance is (i.e in a cpp file), he forgot to actually initialise them in his example, but you get the idea.

02-27-2003, 09:10 AM
Thanks

I'll try it.