Delphi中的图书馆项目是否有条件定义? [英] Is there a conditional define for library projects in Delphi?

查看:43
本文介绍了Delphi中的图书馆项目是否有条件定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个实用程序单元,在一些应用程序和DLL之间共享代码。我想根据当前项目类型(应用程序,程序包或库)有选择地编译此单元的各个部分。我在系统单元中找不到库或程序包的任何条件定义,并且Google找不到任何相关的内容。因此,编译器是否设置了任何条件定义,例如 IsLibrary IsPackage ?顺便说一下,我知道 IsLibrary 变量。

I have a utility unit with code shared between a few applications and DLLs. I'd like to selectively compile portions of this unit based upon the current project type: Application, Package, or Library. I couldn't find any conditional definitions for a library or package in the System unit, and Google didn't find anything relevant. So, are there any conditional defines such as IsLibrary or IsPackage set by the compiler? I'm aware of the IsLibrary variable, by the way.

推荐答案

没有这样的预定义条件,也没有这样的条件。这是因为在编译时无法知道单元最终是否将链接到可执行文件,库或包中。

There is no such pre-defined conditional, and there could not be such a conditional. That's because at compilation time it is impossible to know whether the unit will, ultimately, be linked into an executable, a library or a package.

实际上,同一编译器单位可以链接到上述任何或所有项目类型中。的确,当您将RTL链接到项目中时,您自己可以看到这一点。您可以将相同的系统单元,相同的已编译.dcu文件链接到所有项目中,而与项目类型无关。

In fact, the same compiled unit could be linked into any or all of the above project types. And indeed you can see this yourself when you link the RTL into your projects. You link the same System unit, the same compiled .dcu file, into all your projects, irrespective of the project type.

这篇关于Delphi中的图书馆项目是否有条件定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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