Jump to content
  • Advertisement

Archived

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

samosa

hwnd etc

This topic is 5808 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

i have a cpp file that has all of the parts of a class in it, one of the sections deletes the window, but it needs to have hwnd and all those variables, my main cpp file also needs them, is there a way that i can have the initialized so that both cpp files can use the hwnd variables? ,Matt -= kill one your a murderer, kill thousands your a conquerer =-

Share this post


Link to post
Share on other sites
Advertisement
i tried using a header file but it keeps saying that it has already beed initialized, also, if u use #ifndef #define and #endif it still complains that it has been initialized, plz, someone help

,Matt

-= kill one your a murderer, kill thousands your a conquerer =-

Share this post


Link to post
Share on other sites
Well, to make things less complicated for you, if you''re using MSVC, don''t bother with #ifndef-related preprocesser commands. Just stick a nice little


#pragma once


At the very beginning of your header file, and you shouldn''t have any troubles including it more than once.

Share this post


Link to post
Share on other sites
im afraid that doesnt work, it still says:
Linking...CRender.obj : error LNK2005: "bool fullscreen" (fullscreen@@3_NA) already defined in Main.obj

it says that for my 3 bools and for hdc, hglrc hwnd and hinstance

,Matt

-= kill one your a murderer, kill thousands your a conquerer =-

Share this post


Link to post
Share on other sites
it still says that the bool variables canno be found, there is some error when i try to do extern HDC hDc=NULL;

,Matt

-= kill one your a murderer, kill thousands your a conquerer =-

[edited by - Samosa on June 29, 2002 10:14:04 PM]

Share this post


Link to post
Share on other sites
That''s because you do this in two parts. You declare the actual variable in an implementation file (.c, .cpp, etc), and there you can initialize it. That''s where the variable actually lives. In a header file, you make the external declaration which is not the actual variable, but just tells the compiler that the symbol in question will not be found in the same translation unit as what''s included the header. Since this external declaration is not the actual variable, you do no initialization there (nor would you want to since--again--the actual variable is in an implementation file and you already initialized it there once and only once).

Share this post


Link to post
Share on other sites
wow, finally, after a huge headache and probably annoying merlin9x9 a great deal its working, thank you both for your help, i would have never figured it out without ur help

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!