View previous topic :: View next topic |
Author |
Message |
.C
Joined: 06 May 2004 Posts: 19 Location: Italy
|
Inizialitations variables |
Posted: Sat May 22, 2004 3:14 pm |
|
|
Hi
I have notice about "Static" that it is expensive for inizialitations variables.
There is another way , Do you know it ? |
|
|
.C
Joined: 06 May 2004 Posts: 19 Location: Italy
|
|
Posted: Sun May 23, 2004 1:58 am |
|
|
...Home keeping |
|
|
rwyoung
Joined: 12 Nov 2003 Posts: 563 Location: Lawrence, KS USA
|
|
Posted: Sun May 23, 2004 11:17 am |
|
|
You can use global variables instead of the keyword "static". The downside to a global variable is that it can be altered outside what should be its scope.
Global variables solve lots of problems but can create many more if you do not use discipline when coding. _________________ Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month! |
|
|
.C
Joined: 06 May 2004 Posts: 19 Location: Italy
|
|
Posted: Mon May 24, 2004 2:25 am |
|
|
but ,by static the variable is globally active and initialized to 0,What Does the difference?
May be by static the variable are initialized to 0
if I write
int A -> is global
static int b -> is global and initialized to 0
main() {
//
} |
|
|
rwyoung
Joined: 12 Nov 2003 Posts: 563 Location: Lawrence, KS USA
|
|
Posted: Mon May 24, 2004 7:30 am |
|
|
Code: |
int8 a=0; // initialized to zero
// could as easily said int8 a=99; to initialize as 99
void main(void)
{
}
|
_________________ Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month! |
|
|
|