0

I have found that having a {$I filename} in a unit file apparently prevents Omnipascal from being able to resolve references after that. In the following example, cs1 is not found as a reference unless the {$I filename} is removed from unit_1.pas:

unit MainForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses
  unit_1;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  MessageDlg(cs1, mtWarning, [mbOK], 0);  
end;

end.
unit Unit_1;

interface
{$INCLUDE C:\Junk\Delphi\VSCode Test\2\Units\COMPIL.INC}

const
cs1 = '1';

implementation

end.

Compil.inc:

{$DEFINE TESTDEF}

This is v0.19.0 Am I doing something incredibly silly or does the $I break things?

Paul G
  • 61
  • 1
  • 2
  • 3

0 Answers0