09-02-2017 11:21 AM
my CVI is CVI2013.
in a function called Send(),which is defined myself,i used goto statements to jump out of switch statements inside of for statements.
which is showed below:
int Send()
{
for(...) //the first for
{
if()//the first if
{
for()//the second for
{
switch()
{
case 1:
goto Label1;
}//end of switch
}//end of the second for
}//end of the first if
Label1: continue;
}//end of the first for
}
when i compiled it ,it showes:
" 485, 49 error: use of undeclared label 'Label1'",
"624, 1 error: use of undeclared identifier 'Label1'"
why?
Solved! Go to Solution.
09-03-2017 11:52 PM
With the risk of being simplistic, I would double check that a true colon is used after the label definition and not a semicolon: it's something that sometimes happens to me, they are so similar!
09-04-2017 02:46 AM
in my function, there is not only one "goto Label1",may be the reason of coming faults?
int Send()
{
for(...) //the first for
{
if()//the first if
{
for()//the second for
{
switch()
{
case 1:
goto Label1; /// Number1
break;
case 2:
....
goto Label1; /// Number2
}//end of switch
}//end of the second for
goto Label1; ///Number3
}//end of the first if
Label1: continue;
}//end of the first for
}
similarly above, only defined one Lable "Label1", but have some calling"goto Lable1". Maybe it is the reason?
09-04-2017 04:20 AM
You may have as many goto statements as you want, that's not the problem.
But that "undeclared identifier" error on line 624 probably points exactly to Label1: line which in my hypothesis is not correctly written (e.g. the colon is missing or is replaced by a semicolon)
09-05-2017 12:19 AM
Why don't you simply write continue instead of goto Label1.
goto's are not the best coding practice.
09-07-2017 09:07 AM
Can you copy and paste the exact code? There may be something wrong in the code that's not showing up in the snippets you've posted so far.
09-10-2017 07:47 AM
last time,when i met the troubles when using "goto",i used flags instead of 'goto',and it works.
today,when i see your replys,i used "goto" to recode the source, and now the troubles never appeared.
so, it seems to be very confused me.
maybe, some wrong syntax caused it.
i use tortoiseSVN to record my project,and i forgot to save last "goto" codes last time ,and now it cannot to be reappeared.
thans all.