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]: Unreachable blocks still processed for some macros #201

Closed diamante0018 closed 3 months ago

diamante0018 commented 3 months ago
#define TEST

#ifndef TEST
#error How did this happen
#endif

main()
{
}

Expected behaviour:

#error block should not be processed at all even though it's technically unsupported because ifndef TEST should never trigger because we defined TEST two lines before.

This is the case for C++ compilers

image

Unexpected behaviour:

.\gsc-tool.exe -m comp -g iw5 -s pc .\a.gsc
GSC Tool 1.4.3.297-prod created by xensik
[ERROR]:preprocessor:./a.gsc:4:2: #error directive not supported at ./a.gsc
diamante0018 commented 3 months ago

This still works on C++

image

xensik commented 3 months ago

skip logic is parsing directives to find the #endif, or #elif. i will add skip checks to unimplemented directives