简体   繁体   中英

Shrinking exe by removing RTTI

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 .

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.

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

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