Questions tagged [global]
Refers to a space where variables and other items may be accessed from any scope.
global
4,722
questions
3
votes
5
answers
3k
views
C/C++ Performance Globals vs Get/Set Methods
I saw this question asking about whether globals are bad.
As I thought about the ramifications of it, the only argument I could come up with that they're necessary in some cases might be for ...
3
votes
4
answers
3k
views
C++ variable with same name, context : global and private,
In the following code, g++ gives this error :
1.cpp: In member function void W::test()':
1.cpp:6: error:int F::glob' is private
1.cpp:19: error: within this context
But, shouldn't the globally ...
6
votes
3
answers
4k
views
JavaScript - check if in global context
When a function is attached to an object and called:
function f() { return this.x; }
var o = {x: 20};
o.func = f;
o.func(); //evaluates to 20
this refers to the object that the function was called ...
28
votes
7
answers
99k
views
What is the difference between a static global and a static volatile variable?
I have used a static global variable and a static volatile variable in file scope,
both are updated by an ISR and a main loop and main loop checks the value of the variable. here during optimization ...
6
votes
6
answers
5k
views
Static vs global in terms of speed and space consumption in C
I would like to know difference between static variables and global variables in terms of access speed and space consumption. (If you want to know my platform: gcc compiler on Windows. (I am using ...
1
vote
4
answers
12k
views
defining structures globally in c++
there was a somewhat detailed thread (228684) on how to globally (using extern struct) declare a structure that could be seen in more than 1 c++ file, but I can not figure out exactly how to do it (...
3
votes
3
answers
7k
views
capturing global keypresses in Java
So I want to trigger an event (pausing/unpausing some media) whenever the user presses spacebar anywhere in the my Swing app.
Since there are so many controls and panels that could have focus, its ...
62
votes
12
answers
59k
views
Do you use the "global" statement in Python? [closed]
I was reading a question about the Python global statement ( "Python scope" ) and I was remembering about how often I used this statement when I was a Python beginner (I used global a lot) and how, ...
130
votes
12
answers
193k
views
How to make a cross-module variable?
The __debug__ variable is handy in part because it affects every module. If I want to create another variable that works the same way, how would I do it?
The variable (let's be original and call it '...
29
votes
7
answers
88k
views
global variables in php not working as expected
I'm having trouble with global variables in php. I have a $screen var set in one file, which requires another file that calls an initSession() defined in yet another file. The initSession() declares ...
24
votes
3
answers
37k
views
Best way to tackle global hotkey processing in c#? [duplicate]
Possible Duplicate:
How can I register a global hot key to say CTRL+SHIFT+(LETTER) using WPF and .NET 3.5?
I'd like to have multiple global hotkeys in my new app (to control the app from anywhere ...
10
votes
4
answers
3k
views
How can I avoid global state?
So, I was reading the Google testing blog, and it says that global state is bad and makes it hard to write tests. I believe it--my code is difficult to test right now. So how do I avoid global state?...