delphiuses-clause

Delphi: Which are the downsides of having unused units listed in the uses clause?


I use cnPack Uses cleaner, but in general which are the downsides of having useless units?

I know some of them:

1) of course if the unit is never used across the full project there will be useless resource consuption

2) the code insight will give useless results

3) the code insight will be slower

But imagine a simple case:


Solution

  • No. In general smartlinking works like this:

    Conclusion: the final .exe size is determined

    Free Pascal roughly works in the same way, the defaults are just different; Debug is currently nearly always "in binary" (like TD32), and in snapshots, smartlinking is off by default. (in official releases it is on though).

    Moreover one must not lose sight of the magnitude. Strutils in its entirety is like 15kb max.

    (update 2011-11-01)

    Got a remark from sb on this reply I liked to share:

    Basically he shed doubt on the remark that enums are always linked in. Maybe the registering of a class that has a published property of the enum type drags them in. The reasoning makes sense, but I haven't tested it yet. So RTTI of enum directly can be only linked if typeinfo(tenumtype) is queried somewhere, or if it is used in a published section of the class which is used. (directly or typeinfo(theclass) is queried)