Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > NULL global variable

Reply
Thread Tools

NULL global variable

 
 
person
Guest
Posts: n/a
 
      01-05-2006
Hi,

I've got a global variable, type * var_name, declared in one .cpp file.
I assign it a value inside one of the methods in that file. I extern
it in other .cpp files. For some reason in all the other files it's
NULL (thus causing my program to crash when I try to use it). I know
it's getting assigned a legitimate value because I can use it
successfully in the method right after it's assigned. The declaration
is not static. Will someone please tell me what I'm doing incorrectly?
It was working, then I had to go through a major overhaul of my
including of .h files due to a bizarre inheritance problem. Now it
doesn't work and I don't know if it's a side effect of the include
exercise or if something else has gone haywire. Any help/ideas would
be greatly appreciated.

Thanks,
Frank

 
Reply With Quote
 
 
 
 
BigBrian
Guest
Posts: n/a
 
      01-05-2006
> Will someone please tell me what I'm doing incorrectly?

That's difficult/impossible without seeing code. Without code
anything would be just speculation and not quarenteed to be right
anyway. Post a minimal amount of code which shows the problem, then we
can tell you what's wrong.

 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      01-05-2006
person wrote:
> I've got a global variable, type * var_name, declared in one .cpp file.
> I assign it a value inside one of the methods in that file. I extern
> it in other .cpp files. For some reason in all the other files it's
> NULL (thus causing my program to crash when I try to use it). I know
> it's getting assigned a legitimate value because I can use it
> successfully in the method right after it's assigned. The declaration
> is not static. Will someone please tell me what I'm doing incorrectly?


Simple. You're not following the recommendations of FAQ 5.8.

> It was working, then I had to go through a major overhaul of my
> including of .h files due to a bizarre inheritance problem. Now it
> doesn't work and I don't know if it's a side effect of the include
> exercise or if something else has gone haywire. Any help/ideas would
> be greatly appreciated.


Recompile/Rebuild all.

V
 
Reply With Quote
 
Mike Wahler
Guest
Posts: n/a
 
      01-06-2006

"person" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Hi,
>
> I've got a global variable, type * var_name, declared in one .cpp file.
> I assign it a value inside one of the methods in that file. I extern
> it in other .cpp files. For some reason in all the other files it's
> NULL (thus causing my program to crash when I try to use it). I know
> it's getting assigned a legitimate value because I can use it
> successfully in the method right after it's assigned. The declaration
> is not static. Will someone please tell me what I'm doing incorrectly?
> It was working, then I had to go through a major overhaul of my
> including of .h files due to a bizarre inheritance problem. Now it
> doesn't work and I don't know if it's a side effect of the include
> exercise or if something else has gone haywire. Any help/ideas would
> be greatly appreciated.


You have a bug on line 42.

-Mike


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FWSM/PIX and Dynamic PAT using global IP range vs. global interface vs. global IP Hoffa Cisco 1 10-25-2006 06:50 PM
FWSM/PIX and Dynamic PAT using global IP range vs. global interface vs. global IP Hoffa Cisco 0 10-25-2006 01:04 PM
division by a potentially null global const variable PS C++ 8 04-26-2006 10:31 AM
"stringObj == null" vs "stringObj.equals(null)", for null check?? qazmlp1209@rediffmail.com Java 5 03-29-2006 10:37 PM
Why can't I initialize a global variable to NULL? moxm C Programming 19 08-19-2005 07:28 AM



Advertisments