UPDATE: Even though the above mentions: the question already has an answer, the solution in the linked question does not work in Delphi XE6
Just noticed that all executables generated with Delphi (including Release version) include the names of all types used by that executable and the names of the units they belong to. If you are not careful to remove the RTTI information then it also contains class methods, fields and property names.
What are these strings used for (especially in a Release version)?
Is there a way to prevent type and unit names from being written to the executable?
Steps to reproduce this:
- Create a new Delphi project.
Define a class
{$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])} type TPerson = class private FName: string; public constructor Create(Name: string); destructor Destroy; override; end; constructor TPerson.Create(Name: string); begin inherited Create; FName := Name; end; destructor TPerson.Destroy; begin inherited Destroy; end;
Create an object of that class so that the class is referenced/used.
var person: TPerson; begin person := TPerson.Create('John Doe'); person.Free; end;
Compile the project in Release mode.
- Use a hex viewer and search for the name of the class (TPerson) in the executable.
How can one prevent the class name from being written to the executable?
also:
How can one remove RTTI at the project level so there would be no need to manually go through every included unit and add the {$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])} clause?
I tried adding $RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])} at the top of the .dpr file but this doesn't work in Delphi XE6.