Reputation: 858
I am using Vs 2010 and my application is in C . I have used goto in one function to jump to the return statement present in another function. The function where i used goto is defined below the one where label is present . Does the order of label defining and goto matter in C. I am getting error " label undefined"
regards
Upvotes: 0
Views: 1757
Reputation: 27105
As the webpage for this Visual Studio compiler error says, "The label used by a goto statement does not exist in the function." You're not allowed to goto a different function because of the problems that would cause for local variable definitions.
Upvotes: 3
Reputation: 16305
The goto must be local to the function the label is defined in. If you want to have a non-local jump you should check out setjmp/longjmp.
Upvotes: 3