Shrinking exe by removing RTTI

元气小坏坏 提交于 2019-12-21 02:44:19

问题


In this question (link) it was said that the line below (in each unit) would remove as much RTTI as possible:

    {$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])} 

The posting didn't mention what Delphi version it works with, but I assume D2010. However, when I include the line above, I get this error:

    DCC Fatal Error: E2158 System unit out of date or corrupted: 
    missing TVisibilityClasses.

I'm using a "stock" version of D2010 and have never done anything that I'm aware of that would change the default installation or the libraries.

Any suggestions? TIA

Related question: link.


回答1:


Make sure you put the "{$RTTI" line below the "unit unit1;" line.

Note that as of XE5 and newer, this directive needs to be in each individual unit for which you want to disable RTTI. Before that (as in comments, which applies only to XE4 and below) it could be in the DPR file and would apply to all units in the project.




回答2:


The new RTTI is for Delphi 2010 and up.

It can be removed, but then lots of things will have limited functionality (like JSON conversion, part of DataSnap and many of the newer 3rd party libraries that do ORM or other mappings).

Things depending on TValue are gone anyway.

"old style" RTTI (which was introduced in Delphi 1 and is still present in Delphi 2010) cannot be removed.

So: it is recommended to remove RTTI only from your own units, and not from the RTL and VCL.

--jeroen



来源:https://stackoverflow.com/questions/4025070/shrinking-exe-by-removing-rtti

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!