open-watcom / open-watcom-v2

Open Watcom V2.0 - Source code repository, Wiki, Latest Binary build, Archived builds including all installers for download.
Other
946 stars 156 forks source link

C compiler checks octal literals during preprocessing? #595

Open NovaRain opened 4 years ago

NovaRain commented 4 years ago

The SSL scripts of cRPG Fallout 2 require a C preprocessor for its script compiler to work. The same script line GOption(146, Node010c, 008); didn't produce any error before (official 1.9 or older beta from 2017), but now WCC gives Error! E1163: Invalid octal constant message for the "008". Is this check for octal literals during preprocessing intended? Because using some other C compilers (e.g. GCC, Embarcadero, Orange C) to preprocess the script doesn't give any warning/error about octal either.

jmalak commented 4 years ago

It looks like mistake, C preprocessor code is shared by multiple code parts that some check was included in wrong place. I will review it.

jmalak commented 4 years ago

you can use as workaround wcpp utility (standalone C preprocessor) until it will be fixed in C compiler.

jmalak commented 4 years ago

it is also problem with C++ compiler.

jmalak commented 4 years ago

Please what compiler command line you use?

NovaRain commented 4 years ago

Please what compiler command line you use?

I use these command line options to preprocess scripts: wcc386.exe myscript.ssl -p -fo=myscript.tmp.ssl -w4

jmalak commented 4 years ago

It is related to the change in compilers error handling. OW 1.9 and older versions has simply suppresed any messages during preprocessing. OW 2.0 has enabled messages during preprocessing to show necessary messages and now it show mistakes in compilers that translation phase 6 and 7 is processed for some tokens even if compilers should not do this. I will review code and fix it.

jmalak commented 4 years ago

I fixed compiler preprocessing mode to not process translating phases unnecessary for preprocessing. It suppress unwanted messages. It was changed against previous versions of OW to enable display errors during preprocessing. Original solution was stupid; to suppress "all" messages/errors if in preproccessing mode.

NovaRain commented 4 years ago

I tested the current release (12e1f32) and it seems working well again. Thanks for the fix.

NovaRain commented 1 year ago

Sorry for reopening the issue, but I just found out that the error message pops out again after updating wcc386. I tried some older builds, and the error reoccurs as early as from 2021-01-01 build.

jmalak commented 1 year ago

Please, could you give me reference to code which exhibits the problem.

NovaRain commented 1 year ago

Please, could you give me reference to code which exhibits the problem.

You mean the script code? It's still the same as my first post, some lines which use "008" or "009", For example: https://github.com/BGforgeNet/Fallout2_Unofficial_Patch/blob/f99d771ea34f953c4b0c99ae65116728d2439d90/scripts_src/den/dcmetzge.ssl#L760

If I run wcc386.exe dcmetzge.ssl -p -fo=dcmetzge.tmp -w4 with 2020-12-01 build there's no error message, with 2021-01-01 or newer builds it will generate dcmetzge.ssl(816): Error! E1163: Invalid octal constant message.

jmalak commented 1 year ago

Thanks, I will fix it ASAP.

NovaRain commented 1 year ago

Thanks, I will fix it ASAP.

Hi. Just curious if this is still being looked into. While I can use wpp386 for preprocessing instead, I'd like to use wcc386 as the document from original developers said if possible.

jmalak commented 1 year ago

I have it on my task list, but with lower priority. I thing it is related to complete rework of pre-processor arithmetic to be C99 compliant.