什么时候应该添加对Delphi项目的文件引用? [英] When should I add a file reference to a Delphi project?

查看:70
本文介绍了什么时候应该添加对Delphi项目的文件引用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标准VCL文件(例如Dialogs,StringUtils等)的单元文件从未在项目DPR文件中引用。但是,何时应添加对DPR文件的引用?
现在我有自己的源文件和自己的组件的源。

Unit files for standard VCL files like Dialogs, StringUtils etc is never referenced in a projects DPR-file. But when should I add a reference to the DPR-file ? Now I have own sourcefiles and source of own components.

Ravereport,Devexpress,Indy,Gnostice等的源文件呢?
我想要尽可能快的codeinsight,但是我当然不想在DPR文件中添加膨胀。我使用的是Delphi 2007

What about source files for Ravereport, Devexpress, Indy, Gnostice etc ? I want as fast codeinsight as possible, but of course I do not want to add bloat to the DPR-file. I use Delphi 2007

另请参见此相关问题的问题

致谢

推荐答案

我总是将项目使用的所有我自己的代码单元添加到dpr use子句中。 VCL单元和第三方库中的单元仅在需要时添加。因此,项目的库路径仅包含vcl和第三方库的路径。

I always add all my own code units a project uses to the dpr uses clause. VCL units and units from third party libraries are only added as needed. The project's library path therefore only contains paths to the vcl and third party libraries.

尽管项目无需编译即可将所有单元添加到项目的库中。 dpr,这是一项额外的工作,它使依赖关系显式化,并有助于避免因隐式使用可能在库路径中潜伏的旧 dcu而引起的问题。

While it isn't necessary for the project to compile to add all your units to the project's dpr, and it is a bit of extra work, it makes dependencies explicit and helps avoid problems caused by implicit use of possibly "old" dcu's lurking about on the library path.

当您为不同的项目使用相同的单位名称和不同的内容时,它也很有帮助。对于共享单元使用的项目特定代码很有用。共享单元仅使用 unit1,而dpr表示哪个。与使用库路径相比,这种方法更明确,也更不容易出错。

It also helps when you have the same unit name with different content for different projects. Useful for project specific code used by a shared unit. The shared unit simply uses "unit1" and the dpr says which one. More explicit and less error prone than using the library path.

项目的dpr也总是包括所有使用的组件,vcl或第三方的路径。我的环境选项中的库路径为空。它甚至不包含vcl的路径。也许有点(在顶部),但是嘿,检查起来很容易...

The project's dpr also always includes the path's to all components used, vcl or third party. The library path in my environment options is empty. It does not even contain the paths to the vcl. That may be a bit ott (over the top), but hey it is easy to check...

再次,这有助于使依赖关系明确,当您使用路径中具有自己的环境变量,例如$(MVC)\ComponentName\Source,在将代码传送到另一台计算机时也有帮助。我唯一需要做的就是复制很多内容(或将其放在USB记忆棒上)并在Delphi IDE中设置MVC环境变量。而且我可以放心,在构建我的项目时,另一台计算机上安装的任何内容都不会受到干扰。

Again, this helps to make dependencies explicit and when you use your own environment variable in the paths, for example $(MVC)\ComponentName\Source, it also helps when carrying your code to another('s) machine. The only thing I need to do is copy the lot over (or carry it on an USB stick) and set the MVC environment variable in the Delphi IDE. And I can rest assured that whatever is installed on the other machine won't interfere when building my project.

这篇关于什么时候应该添加对Delphi项目的文件引用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆