Advertisement

What is wrong with this?

Started by August 17, 2000 02:18 PM
7 comments, last by Grugnorr 24 years, 4 months ago
.-Hi! I´m having this error: error LNK2001: unresolved external symbol "private: static struct HWND__ * CDirectScreen::_hwnd" (?_hwnd@CDirectScreen@@0PAUHWND__@@A). .-I have a class CDirectSurface with a static private variable, HWND _hwnd. To use it from outside the class I have two static public methods :SetHwnd and GetHwnd(). When I do SetHwnd(handle) I get that linking error. What is the problem? .-Thanks you in advance for your help... What the hells!
What the hells!
this might be dumb to ask... but i can''t assume anything...

are you #including <windows.h> in the file with your CDirectSurface class in it?

"Man is the only animal that laughs and weeps; for he is the only animal that is struck with the difference between what things are and what they ought to be."
        --William Hazlitt
Greenspun's Tenth Rule of Programming: "Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified bug-ridden slow implementation of half of Common Lisp."
Advertisement

.-Yes I do. Do someone have a piece of code doing this that really works?

.-Thanks for helping...

What the hells!
What the hells!
I think I''ve figured it out:
It''s an inline method, right? This access method? You''re trying to inline access a private static, and it barfs because it''s not linked ( after all, it''s private ).
This would be one sick compiler bug.
Try making that static member protected.


Give me one more medicated peaceful moment.
~ (V)^|) |<é!t|-| ~
ERROR: Your beta-version of Life1.0 has expired. Please upgrade to the full version. All important social functions will be disabled from now on.
It's only funny 'till someone gets hurt.And then it's just hilarious.Unless it's you.

.-I´ve tried it setting _hwnd as protected. Nothing changes!.

.-I´ve also put the static function´s code outside the class definition, that is, not doing them inline->Nothing changes!.

.-Please help!!!



What the hells!
What the hells!
Are you declaring the static member outside the class declaration? You should have a declaration like:

HWND CDirectScreen::_hwnd = 0;

somewhere in your source file.
Advertisement

.- I´ve tried to put _hwnd as protected->Nothing changes...

.- I´ve tried putting the static functions outside the class definition, that is, not setting them as inline->Nothing changes...

.-Please help!!!

What the hells!
What the hells!

.-THANKS!!!!! it was that:I had to do this in the source file:
HWND CDirectSurface::_hwnd=NULL;

.-But... Why do I have to initialize it?



.-Other thing:You can see that I´ve send a post twice, when I click this message in the recent threads section I don´t see any of them, I only see until the MadKeith message-> The message software is corrupted. It also displays some messages with replies as with no replies, and other with no replies with some!


Thanks to everyone for helping me, and specially to you Anonymus Poster(not registred?->Why?)...


What the hells!
What the hells!
quote:
The message software is corrupted. It also displays some messages with replies as with no replies, and other with no replies with some!


Here we go again... This has been brought to everyone's attention many times now - we all know that the forum doesn't display the correct amount of replies sometimes. It's also appears to be not 100% Y2K compatible (it displays 12/31/1899 as the date sometimes). So please don't mention it again - we already know it

Edited by - Muzzafarath on August 18, 2000 11:07:56 AM
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall

This topic is closed to new replies.

Advertisement