Simple variable in loop causes trouble...
why code here below doesn't work? it appears "doit" not assigned value of 0 in beginning code doesn't run on first run.
void loop() {
static int doit= 0;
while (doit==0) {
// run code...
doit = 1;
}
...
}
if declare "doit" global variable, works fine :
int doit= 0;
void loop() {
while (doit==0) {
// run code...
doit = 1;
}
...
}
i *really* don't it. and btw if following works :
void loop() {
int doit= 0;
while (doit) {
// run code... the code run
doit = 0;[font=courier][/font]
}
}
it's not first time program, it's been years (c under unix) above makes no sense me. could bug compiler?! i'm under windows 7 64 bits arduino version 0017.
thanx / clue.
pierre
void loop() {
static int doit= 0;
while (doit==0) {
// run code...
doit = 1;
}
...
}
if declare "doit" global variable, works fine :
int doit= 0;
void loop() {
while (doit==0) {
// run code...
doit = 1;
}
...
}
i *really* don't it. and btw if following works :
void loop() {
int doit= 0;
while (doit) {
// run code... the code run
doit = 0;[font=courier][/font]
}
}
it's not first time program, it's been years (c under unix) above makes no sense me. could bug compiler?! i'm under windows 7 64 bits arduino version 0017.
thanx / clue.
pierre
whenever suspect compiler do
this helps clarify if compiler blame or not.
cheers, udo
code: [select]
avr-objdump foo.elf -s -s >bar
gedit bar
this helps clarify if compiler blame or not.
cheers, udo
Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > Simple variable in loop causes trouble...
arduino
Comments
Post a Comment