unqualified-id

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
mikep1958
 
Posts: 3
Joined: Fri Feb 17, 2012 10:31 am

unqualified-id

Post by mikep1958 »

I am getting this "expected unqualified-id before 'goto'"

What is an unqualified-id ?

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: unqualified-id

Post by adafruit_support_bill »

It would help if you posted the code that causes the error.

mikep1958
 
Posts: 3
Joined: Fri Feb 17, 2012 10:31 am

Re: unqualified-id

Post by mikep1958 »

//#####################################################
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;

mikep1958
 
Posts: 3
Joined: Fri Feb 17, 2012 10:31 am

Re: unqualified-id

Post by mikep1958 »

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;
}

mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am

Re: unqualified-id

Post by mtbf0 »

sheesh. haven't seen a goto in years.

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);
}
or the c way like this...

Code: Select all

void loop() {
  while (1) {
    analog_input=analogRead(analogPin);
    Serial.print("analog input is ");
    Serial.println(analog_input,1);
  }
}

User avatar
philba
 
Posts: 387
Joined: Mon Dec 19, 2011 6:59 pm

Re: unqualified-id

Post by philba »

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.

User avatar
baldengineer
 
Posts: 127
Joined: Sun Sep 26, 2010 11:49 pm

Re: unqualified-id

Post by baldengineer »

Why are you using goto? There is no need in this case because void loop() is a loop that runs continuously already.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”