Delphi for .NET contains the following compiler defines:



This means that you might want to write code like the following (using the Linux® compiler define to complete the Delphi platform alternatives):

project HelloWorld; {$APPTYPE CONSOLE} begin

  • IFDEF CLR} // Delphi for .NET writeln('Hello, .NET world!'); {$ENDIF}
  • IFDEF WIN32} // Delphi 7 writeln('Hello, Win32 world!'); {$ENDIF}
  • IFDEF LINUX} // Kylix writeln('Hello, Linux world!'); {$ENDIF} end..

Note that we now have three possible platforms, so you should not use {$ELSE} to write code that is not suited for one particular platform. Even if you are certain today that the code is right, future support for other platforms might break your code. Always use specific {$IFDEF} sections to write code for a specific platform.

VCL, VCL for .NET, and Windows® Forms

When Delphi first shipped in 1995, the component library was called the Visual Component Library. It contained more than just visual components, however. A number of these components are platform-independent, and it was mainly the visual components that were specifically bound to the Windows API and controls.

Was this article helpful?

0 0

Post a comment