Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/IDE/Code Editor    [ Add a report in this area ]  
Report #:  111178   Status: Open
Uses clause doesn't respect definitions in include file
Project:  Delphi Build #:  17.0.4625.53395
Version:    17.0 Submitted By:   Christian Holzner
Report Type:  Basic functionality failure Date Reported:  12/8/2012 1:14:51 AM
Severity:    Serious / Highly visible problem Last Updated: 12/8/2012 11:43:35 PM
Platform:    All versions Internal Tracking #:   34296
Resolution: None (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: (4 Total Ratings)
5.00 out of 5
Total Votes: 51
Description
I have various define statements for handling different Delphi versions in an include file. This include file is "included" in an unit. The compiler respects the defines given in the include file but the IDE not. This results in an addition of certain units to the uses clause which are can be already there - enclosed in a DEFINE compiler directive.

Therefore, if a unit is added which isn't available in pre Delphi XE3 you will have a big problem because if you let the IDE add the unit and can not compile it with a pre Delphi XE3 version which doesn't have that unit.
Steps to Reproduce:
1. MYINCLUDE.INC only one define
-------------
{$DEFINE DELPHIXE3}
-------------

2. A sample unit may look like
-------------
unit Unit1;

interface

{$I MYINCLUDE.INC}

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs,

  {$IFDEF DELPHIXE3} System.Actions, {$ENDIF}

  Vcl.ActnList;       // <---- This "System.Actions" statement is always added from the IDE, even if I have it definied already (see line above). This results in an "Identifier redeclard" compiler error. If you delete it the IDE will add it again the next save.

type
  TForm1 = class(TForm)
    ActionList1: TActionList;
  private
  public
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

end.
-------------

3. After a save the IDE adds "System.Actions" add the end of the uses list which in turn results in  an "Identifier redeclard" compiler error. If you delete it the IDE will add it again the next save.
Workarounds
None
Attachment
Projects.zip
Comments

Ulrich Amann at 12/9/2012 1:09:14 PM -
I can confirm this bug, and it's very annoying... :-(

Jan Martin Pettersen at 12/11/2012 6:30:12 AM -
It doesn't have to be in a include file to get ignored by the IDE.

If you have {$Ifdef VER240},System.Actions{$Endif} (VER240 is XE3) inside the uses list, then
the IDE still inserts a System.Actions into it if you view the sourcecode of a unit using TActionList or similar and start a compile/build/save.

This also results in E2004 Identifier Redeclared: 'System.Actions' error.

It is annoying.

Server Response from: ETNACODE01