I'm not experienced in Delphi at all and I have a very old project that can be compiled in Delphi of 2nd,3rd versions but isn't working in Delphi 4. The problem is about pointers that are working differently in the newer version.
These pieces of code cause error "Variable required":
pEnabled := @pClrWire_s^.enabled;
pEnabled := @Enabled;
pNEnabled := @pName_s^.Enabled;
where pEnabled is:
const
pEnabled : ^boolean = nil;
and pClrWire_s and pName_s are pointers as well:
pClrWire_s : TpImage; {pointer to an image of colored wire}
pName_s : TpNamed; {pointer to the identifier}
Description of TpImage and TpNamed are found in other files of the project:
type
TpImage = ^TImage;
TpNamed = ^TNamed;
TNamed = class(TLabel)
Can this problem be solved without serious rewriting of the whole code? and what causes such problem with Delphi 4?
Here is a complete solution tested with latest Delphi (D10.3 which really is Delphi version 26 if you compare with early Delphi version number, but that is an other story):
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages,
System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls;
type
TpImage = ^TImage;
{$J+} // enable writable constant
const
pEnabled : ^boolean = nil;
var
pClrWire_s : TpImage;
type
TForm1 = class(TForm)
private
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
end.
As Dalija Prasnikar and Gerry Coll said in their respective comment, the key is to enable assignable typed constant. You can do it either using {$J+} in the source code or using the project options located at Project options / Building / Delphi compiler / Compiling / Syntax options / Asignable typed constant.
Let me know if it works for you.