Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.

Sander Aerts

Redefinitions of variables in my .h's, when using ifndef

This topic is 5805 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I have i problem that my linker is bugging me about redefintions of vars in the file globals.h, but i have a ifndef in the file to check if the header is already loaded or not but this doesn''t seem to work very well You can see the header on : http://www.drsnugels.nl/piemel/globals.h I hope somebody can take a look @ it and give me some advice in here, i am almost getting nuts right now. ------ With kind regards, Sander Aerts

Share this post

Link to post
Share on other sites
Hrm... I think I had a similar problem awhile back... not sure exactly what I did about it though. Could you post the compiler error log?

Share this post

Link to post
Share on other sites
Make a globals.cpp and put the variable definitions in it. Then change all the definitions you had in it to have extern in front of them. So...

HWND hWnd;
HINSTANCE hInstance;
bool active;
bool keystrokes[256];
gl_options gl_init_opt;

goes in the cpp file and you change them to

extern HGLRC hRC;
extern HDC hDC;
extern HWND hWnd;
extern HINSTANCE hInstance;
extern bool active;
extern bool keystrokes[256];
extern gl_options gl_init_opt;

in the globals.h file.
[NOTE: you will need to include windows.h and gl.h in the cpp file]

The system you have set up prevents the header from being included multiple times in the same file (like through another file that also includes globals.h) but not if two separate files include it.

Share this post

Link to post
Share on other sites
Ok thank you guys for the input!, i will try it tommorow morning.


With kind regards,

Sander Aerts aka DrSnugels

mov ax, 013h; int 10h; mov ax, 0xa000h;
mov es, ax; mov di, 3360; mov al, 15;
stosb; mov ax, 0002h; int 21h;
mov ax, 03h; int 10h;

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!