Is WEBLIB the correct compiler directive

I have generic conditional code for VCL and TMS Webcore in the same shared unit.

  • I have used {$ifdef WEBLIB} to compile it in and out. Compiling and Execution works fine.

  • However, in the IDE it has all the code for WEBLIB in dim and the Editor shows an error (for identifier not found).

  • So I added WEBLIB to Options -> Building -> Delphi Compiler ->Conditional Defines

But the issue remains. How can I get this working?


Showing in Dim

06.04.2025_16.56.10_REC

Showing Error in IDE

06.04.2025_16.56.31_REC

If you want to make the difference between compiling for web and not compiling for web, you can use the define
{$IFDEF PAS2JS}

That works as in it compiles correctly. However, the Editor still shows it incorrectly. So, I assume its a bug in 12.3

You tried to add it to the project options of the web project you are working in?

Yes, without adding or with adding to options, the Compiler works, but the editor shows those blocks in gray.

I don’t know why the editor doesn’t pickup a project level define.

I will try a previous version of Delphi and then file a bug report.

Has this been fixed, because its sort of what I am getting.

Hi Bruno,

The project level define works fine with the Delphi compiler for VCL. The problem is PAS2JS. It does not see it. If I define it in the pascal file itself, it can see it. But I need it at the project level. I would appreciate if this could this be fixed soon please.

I can only assume this is an IDE issue, we do not interfere or control in any way with how project level conditional defines are being treated by the IDE editor.

Well, the IDE works fine for non TMSWEBCORE projects. I just tried. I had another Delphi user try it as well.

Perhaps the IDE does not make it available automatically and it has to be fetched by the compiler (from the project.options).

Maybe there is something else in your code causing the LSP to hickup.
Select from the TMS WEB Core toolbar in the IDE to compile the project with DCC. Compiling with DCC doesn't make sense except to show where in the code the DCC has problems with your code. Then try to fix / comment this code and see if it has effect.

Another non-obvious feature. :-)

I hadn't spotted the Compiler directive in the TMS Webcore portion.

If I set say FORWEB in
Options-> TMS Web -> Compile -> Directives,
then PAS2JS is happy.

If I set FORWEB it in
Options -> Building -> Delphi Compiler -> Conditional Defines,
then the LSP is happy.

For best results, I have to put it in both. This is for Delphi 12.3. Other versions may behave differently.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.