How Delphi Compiles my code

How will the Delphi compiler compiles the following code ;

uses a_big_unit;


procedure TForm1.Button1Click(Sender: TObject);
var
acompont : T_a_big_component ;
begin

if (true = false ) then // or            if false then
begin
  bc :=  Tbig_component.create(self)

end;

in this code true = false will never happen so component acompont will never created .

when delphi is compiling in optimized mode will these unused units and code are omitted

AND WHEN using units

in delphi 7 , even if you just uses XPMan unit; (without using any components it has(TXPManifest1)) , still the unit is used and every components are shown with theme ;

and some said Delphi will omit units if it is not needed ;

So how Delphi identifies whether a unit has an impact on the unit it calls or not

Answers


See for yourself: Compile the code and run it in the debugger. You won't be able to set a breakpoint on any statements inside the if false then block, and you won't be able to set any breakpoints in the constructor of the Tbig_component class in the other unit. Why? Because there isn't any code for these statements.

You can also view the machine code generated by the compiler by opening the Disassembly view in the IDE. It will show the machine code for each source line. You'll find there will be no machine code generated for the if false then block.


Need Your Help

Getting HTML to recognize \n and \t

html string asp.net-mvc-3

I have created a web application using ASP.NET MVC3, and want to display a string (that I constructed in the constructor) in a view. This string has \n and \t characters in it, and I want that form...

How to delete certificate from Keychain Access?

ios4 xcode4 keychain

When I try to delete certificate in Keychain Access I get following error

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.