I am getting this "expected unqualified-id before 'goto'"
What is an unqualified-id ?
unqualified-id
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: unqualified-id
It would help if you posted the code that causes the error.
-
- Posts: 3
- Joined: Fri Feb 17, 2012 10:31 am
Re: unqualified-id
//#####################################################
const int analogPin=A0;
float analog_input;
//====================================================================
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop() {
repeatLoop1:
analog_input=analogRead(analogPin);
Serial.print("analog input is ");
Serial.println(analog_input,1);
}
goto repeatLoop1;
const int analogPin=A0;
float analog_input;
//====================================================================
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop() {
repeatLoop1:
analog_input=analogRead(analogPin);
Serial.print("analog input is ");
Serial.println(analog_input,1);
}
goto repeatLoop1;
-
- Posts: 3
- Joined: Fri Feb 17, 2012 10:31 am
Re: unqualified-id
I found it :
stupid mistake
//#####################################################
const int analogPin=A0;
float analog_input;
//====================================================================
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop() {
repeatLoop1:
analog_input=analogRead(analogPin);
Serial.print("analog input is ");
Serial.println(analog_input,1);
goto repeatLoop1;
}
stupid mistake
//#####################################################
const int analogPin=A0;
float analog_input;
//====================================================================
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop() {
repeatLoop1:
analog_input=analogRead(analogPin);
Serial.print("analog input is ");
Serial.println(analog_input,1);
goto repeatLoop1;
}
-
- Posts: 1645
- Joined: Sat Nov 10, 2007 12:59 am
Re: unqualified-id
sheesh. haven't seen a goto in years.
why not the arduino way like this...
or the c way like this...
why not the arduino way like this...
Code: Select all
void loop() {
analog_input=analogRead(analogPin);
Serial.print("analog input is ");
Serial.println(analog_input,1);
}
Code: Select all
void loop() {
while (1) {
analog_input=analogRead(analogPin);
Serial.print("analog input is ");
Serial.println(analog_input,1);
}
}
- philba
- Posts: 387
- Joined: Mon Dec 19, 2011 6:59 pm
Re: unqualified-id
I do love the GCC compilers error messages. Even some one with MANY years of C/C++ experience has to scratch his head over them.
"unqualified" referred to the fact that the target was at a lower level - basically it didn't want to let you jump into the middle of a nested block (a loop in this case).
BASICally, you should never have to use a goto in C. I suggest you ban all thought of it as it will only get you into trouble. C has a rich set of looping capabilities (while, for and do) as well as break and continue.
"unqualified" referred to the fact that the target was at a lower level - basically it didn't want to let you jump into the middle of a nested block (a loop in this case).
BASICally, you should never have to use a goto in C. I suggest you ban all thought of it as it will only get you into trouble. C has a rich set of looping capabilities (while, for and do) as well as break and continue.
- baldengineer
- Posts: 127
- Joined: Sun Sep 26, 2010 11:49 pm
Re: unqualified-id
Why are you using goto? There is no need in this case because void loop() is a loop that runs continuously already.
Please be positive and constructive with your questions and comments.