简体   繁体   中英

Delphi {$INCLUDE filename} in uses part of dpr file

I have many Delphi 10 projects that are using the same units, let's call them "commons".

When I add anew unit to commons, I have to manually add it to each project. I have tried adding a {$INCLUDE commons.inc} line into the uses part of each .dpr file:

uses
    Forms,
    {$INCLUDE commons.inc}
    projectUnit1,
    ...;

commons.inc has this content:

common1,
common2,

I can compile a project but cannot manage the units from commons.inc . By manage, I mean Ctrl-F12 , remove from project, etc.

This is from Delphi's help:

There is one restriction to the use of include files: an include file can't be specified in the middle of a statement part. In fact, all statements between the begin and end of a statement part must exist in the same source file.

I suppose that is why my idea does not work?

Am I doing something wrong, or is there another solution?

This workaround might suit. The only downside I have found so far is that the included files do not appear in the Project Manager.

  • Add the folder(s) containing the files to be included to the search path of every project.
  • Create Include.pas, a normal .pas file, and include it in the normal way in every project.
  • Add the files to be included in multiple projects to the uses clause of Include.pas. $IFDEFS can be used if required.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM