J2Kbr / GtunerIV

Gtuner IV - Titan Two's software bug report.
http://www.consoletuner.com
25 stars 4 forks source link

Compiler Error Using "goto" #371

Closed MaxRat08 closed 4 years ago

MaxRat08 commented 4 years ago
main
{
    goto EndOfMain;

    EndOfMain:

}

Will fail to compile returning "GPC error: test.gpc(7): syntax error, unexpected B_E '}'."

main
{
    goto EndOfMain;

    EndOfMain:
    0;
}

Placing any instruction after the label will let the program compile successfully.

J2Kbr commented 4 years ago

In the GPC script language (as well as in C/C++) is required labels belong to a statement, therefore a simple semicolon ; after your label can circumvent the problem you are running in to, since that counts as a statement.

Example:

main {
    goto EndOfMain;
    //
        // script code here
        //
    EndOfMain:;
}