LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

troubles about using goto statements

Solved!
Go to solution

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?

 

0 Kudos
Message 1 of 7
(4,629 Views)
Solution
Accepted by topic author winter1970

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! 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 7
(4,570 Views)

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?

0 Kudos
Message 3 of 7
(4,562 Views)

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)



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 7
(4,555 Views)

Why don't you simply write continue instead of goto Label1.
goto's are not the best coding practice.

S. Eren BALCI
IMESTEK
0 Kudos
Message 5 of 7
(4,541 Views)

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.

0 Kudos
Message 6 of 7
(4,492 Views)

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. 

0 Kudos
Message 7 of 7
(4,473 Views)