如何为整个项目设置$ RTTI指令? [英] How can I set the $RTTI directive for the entire project?

查看:231
本文介绍了如何为整个项目设置$ RTTI指令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从Delphi 2007迁移一个旧的项目到Delphi 2010。我发现一个事实是,生成的可执行文件的大小已经增加了一倍以上,原来已经很大了。 (超过50 MB)我怀疑很多与扩展RTTI有关。



由于该项目早于Delphi 2010,因此它不会在任何地方使用扩展RTTI我想保守地包含它。有没有办法使用项目选项对话框来全局设置默认值为$ code> {$ RTTI EXPLICIT METHODS([])PROPERTIES([])FIELDS([])} 我本来希望在这个地方有一个选项(和 $ WEAKLINKRTTI ),但我看不到它们。



有人知道这是否可以从传递给编译器的其他选项字段或其他方式完成?我真的宁愿不必为项目中的每个单元添加一个包含文件,因为有几千个...

解决方案

自XE6以来,$ RTTI指令的行为已经更改,因为实际上它是一个 bug ,因为它应该是当前单位的本地(实际上是记录为自Delphi 2010 )。



此外,即使在一个单元中,也可能会导致使用该伪指令的致命影响因为这个错误,它基本上改变了影响以下单位的全局标志(按编译顺序)。


I'm working on migrating an old project from Delphi 2007 to Delphi 2010. One thing I've found is that the resulting executable has more than doubled in size, and the original was already quite big. (Over 50 MB.) I suspect that a lot of it has to do with extended RTTI.

Since the project predates Delphi 2010, it doesn't use extended RTTI anywhere, and I'd like to be conservative about including it. Is there any way to use the Project Options dialog to globally set {$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])} as the default? I'd have expected there to be an option for this (and for $WEAKLINKRTTI) somewhere, but I don't see them.

Does anyone know if this can be done from the "Additional options to pass to the compiler" field, or some other way? I'd really prefer not to have to add an include file to every single unit in the project, as there are a few thousand of them...

解决方案

The behavior of the $RTTI directive has been changed since XE6 because actually it was a bug because it was supposed to be local to the current unit (and it was actually documented as that since Delphi 2010).

Also it could have fatal affects using the directive at all even in one unit because due to the bug it basically switched a global flag affecting the following units (as in the order of compilation).

这篇关于如何为整个项目设置$ RTTI指令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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