I have now thoroughly checked this issue again with Lazarus versions 1.2.6, 1.6.2, 1.8.4 and 2.0.2 on Linux, macOS and Windows.
If I use the
LCL_FullVersion conditional (or some of its equivalents like
LCL_MAJOR) in the implementation part everything works well. However, using it in the interface part raises the error as described. See a short example in the next section or in the attached file with a demo project. This project can only be compiled after commenting out lines 10 to 12 of unit1.
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
ExtCtrls, LCLVersion
{$IF LCL_MAJOR >= 2} // <- This doesn't work
, LazVersion
{$ENDIF}
;
...
implementation
...
procedure TForm1.FormCreate(Sender: TObject);
begin
{$IF LCL_MAJOR >= 2} // <- This works
RadioGroup1.ItemIndex := 2;
{$ELSE}
{$IF LCL_MAJOR >= 1}
RadioGroup1.ItemIndex := 1;
{$ELSE}
RadioGroup1.ItemIndex := 0;
{$ENDIF}
{$ENDIF}
end;
end.
This is a pity, since conditionals are much more needed at compile time than at runtime.