xensik / gsc-tool

A utility to compile & decompile IW engine game scripts.
GNU General Public License v3.0
214 stars 40 forks source link

[preprocessor]: Surrounding #inline under other macros will brick the tool #203

Closed diamante0018 closed 3 months ago

diamante0018 commented 3 months ago
#define TOOL

#if defined(TOOL)
#inline scripts\mp\_utility;
#else
// empty
#endif

Unexpected behaviour: Com_ERROR: [ERROR]:preprocessor:scripts/mp/_utility.gsh:136:1: missing #endif

Expected behaviour: Compilation succeeds

Using https://git.alterware.dev/AlterWare/jump-gsc/src/branch/main/iw5/scripts/mp/_utility.gsh

Note!!! There is nothing wrong with the header when used on Plutonium IW5 https://git.alterware.dev/AlterWare/jump-gsc/src/branch/main/iw5/scripts/mp/_jump.gsc#L7 Here there is a single #inline and there are no issues

diamante0018 commented 3 months ago

Smaller example

_test.gsh

#define TEST print("hello")

main gsc

#inline _test;

main()
{
    TEST;
}
.\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

HOWEVER

main gsc

#if 1
#inline _test;
#endif

main()
{
    TEST;
}
.\gsc-tool.exe -m comp -g iw5 -s pc .\a.gsc
GSC Tool 1.4.3.297-prod created by xensik
[ERROR]:preprocessor:_test.gsh:2:1: missing #endif at ./a.gsc