Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[preprocessor]: Unable to work with methods #202

Closed
diamante0018 opened this issue Mar 20, 2024 · 3 comments
Closed

[preprocessor]: Unable to work with methods #202

diamante0018 opened this issue Mar 20, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@diamante0018
Copy link
Contributor

#define METHOD_TEST( ent ) \
    if ( ent isHost() ) \
    { \
        continue; \
    }

main()
{
    thread onPlayerConnect();
}

onPlayerConnect()
{
    while ( true )
    {
        level waittill( "connected", player );

        METHOD_TEST( player );
    }
}

Expected behaviour:
Compilation succeeds because ent isHost() is a GSC method and should be replaced correctly when the macro expands

Unexpected behaviour:

 .\gsc-tool.exe -m comp -g iw5 -s pc .\a.gsc
GSC Tool 1.4.3.297-prod created by xensik
[ERROR]:compiler:./a.gsc:2:14: missing ';' ? at ./a.gsc

Manually fixed version which proves something is wrong with the preprocessor

main()
{
    thread onPlayerConnect();
}

onPlayerConnect()
{
    while ( true )
    {
        level waittill( "connected", player );

        if ( player isHost() )
        {
            continue;
        }
    }
}
.\gsc-tool.exe -m comp -g iw5 -s pc .\a.gsc
GSC Tool 1.4.3.297-prod created by xensik
compiled iw5/a.gscbin
@diamante0018
Copy link
Contributor Author

Another example

main()
{
    thread onPlayerConnect();
}

#define PLAYER_NOTIFY_CMD(ent, str, action) ent notifyOnPlayerCommand( str, action )
onPlayerConnect()
{
    while ( true )
    {
        level waittill( "connected", player );

        if ( player isHost() )
        {
            continue;
        }

        PLAYER_NOTIFY_CMD( player, "load_saved_pos", "+activate" );
    }
}
 .\gsc-tool.exe -m comp -g iw5 -s pc .\a.gsc
GSC Tool 1.4.3.297-prod created by xensik
[ERROR]:compiler:./a.gsc:6:49: missing ';' ? at ./a.gsc

@diamante0018
Copy link
Contributor Author

Smaller example:

#define TEST_FUNC(num) myfunc( num )
#define TEST_METHOD( ent, num ) ent mymeth( num )


myfunc( num )
{
    print( num );
}

mymeth( num )
{
    print( num );
}

main()
{
    TEST_FUNC( 5 );
    TEST_METHOD( level, 6 );
}
.\gsc-tool.exe -m comp -g iw5 -s pc .\a.gsc
GSC Tool 1.4.3.297-prod created by xensik
[ERROR]:compiler:./a.gsc:2:37: missing ';' ? at ./a.gsc

@xensik
Copy link
Owner

xensik commented Mar 20, 2024

need to add preprocess command to dump pre-parse token to file output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants