Difference between adding a unit to the interface or the implementation section

后端 未结 5 1960
眼角桃花
眼角桃花 2020-12-10 18:06

If I have a unit that is filled with constants like...

unit AConsts;
interface
const
   Const1 : WideString = \'Const1\';
   Const2 : WideString = \'Const2\'         


        
5条回答
  •  [愿得一人]
    2020-12-10 18:34

    The IDE also uses how where you declare your uses to ascertain what it needs to compile.

    If your interface section uses UnitA and your implementation section uses UnitB then, if unit B needs recompiling, your unit won't, but if unitA changes then your unit will need to be recompiled.

    It's one of the secrets of Delphis super fast build speed.

    As to your finished executable, I expect that it will turn out the same size wherever you put the declarations (the linker is clever and only links in methods etc that are actually used by your application), but the actual location of various sources would almost certainly change if the order of the unit declarations is changed.

提交回复
热议问题