So that errors can already be displayed when coding in Codesys, there is the "precompiler", which underlines errors in the editors.

The precompiler does not generate any code!!!
Therefore, the message of the build process are the decisive ones

Unfortunately, there can be different displays between the precompilation and the actual compilation process (as demonstrated in the following example with the compiler version V3.5.16.30).

If desired, the precompiler can be switched off via the option "Tools\Options...\SmartCoding\Underline errors in the editor".