Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change VCL code?

I need (to make some quick and dirty tests) to modify the code of Variants and SysUtils.

What I need to do to "compile" the changes?

I can of course open those units in the IDE, but if I change them and I buoild a project again I don't see those units recompiled.

What is needed to be done?

like image 912
LaBracca Avatar asked Mar 29 '12 08:03

LaBracca


2 Answers

The problem is you would need to compile ALL of the RTL/VCL against the 'new' units.

Instead modify a copy of the units in question and add them to your project when you want to use them. Delphi should use these over those in the RTL/VCL.

like image 79
Lloyd Avatar answered Sep 20 '22 21:09

Lloyd


Unless you do not change the interface part of the unit (that is, you only modify the implementation side), you can make your own version of the RTL units (only exception is System.pas and SysInit.pas, but this is not in your scope - see our blog site for some enhancements of those units).

What you need is to put your own version of Variants.pas and SysUtils.pas in the search path of your project. They will be taken in account instead of the default RTL.

But be aware that you may easily break anything.

For testing purpose, this is OK, but if you want to use those modifications, you shall better use some automated regression tests, and know explicitly what you are doing.

Please note that you can use the "debug" version of the RTL units (from the project options), then step with the debugger within the official source code. It may help finding issues without touching the source.

If you change the interface part of the unit, you'll have to recompile all units which call the modified unit - for SysUtils and Variants, this is almost all RTL.

like image 43
Arnaud Bouchez Avatar answered Sep 21 '22 21:09

Arnaud Bouchez