Is this a compiler error or a feature of the C language?

My environment is Windows XP SP3 + "Microsoft (R) 32-bit C / C ++ The optimizing version of the compiler is 14.00.50727.762 for 80x86." The process is as follows:

F: \ workshop \ vc8proj \ console> type tc

int main(void) { // Do some thing. { int i; { i = 3; goto abc111; } abc111: } return 0; } 

F: \ workshop \ vc8proj \ console> cl / MD tc Microsoft (R) 32-bit C / C ++ Optimizing Compiler Version 14.00.50727.762 for 80x86

Copyright (C) Microsoft Corporation. All rights reserved.

tc tc (10): error C2143: syntax error: missing ';' before '}'

F: \ workshop \ vc8proj \ console> vim tc

F: \ workshop \ vc8proj \ console> type tc

 int main(void) { // Do some thing. { int i; { i = 3; goto abc111; } abc111: 5201314; } return 0; } 

F: \ workshop \ vc8proj \ console> cl / MD tc Microsoft (R) 32-bit C / C ++ Optimizing Compiler Version 14.00.50727.762 for 80x86

Copyright (C) Microsoft Corporation. All rights reserved.

tc Microsoft (R) incremental linker, version 8.00.50727.762 Copyright (C) Microsoft Corporation. All rights reserved.

/out:t.exe t.obj

F: \ workshop \ vc8proj \ console>

Under Linux, is the same situation ???

+4
source share
2 answers

This is a language feature. A label can only be part of a labeled statement, and the statement must end ; . Just put a semicolon behind the label.

 int main(void) { // Do some thing. { int i; { i = 3; goto abc111; } abc111: ; } return 0; } 

also works.

+10
source

Well, this is a feature of the language. There must be an expression in which we mentioned the label.

If there are no statements after the label, just put ";" complete the statement or you can write the return statement only after the label.

+1
source

All Articles