Writing code to support multiple platforms
While the bulk of your code will be the same regardless of the platform upon which it's running, there will be some cases where you want to do things differently or provide different options if the application is running on a specific device. These unique application characteristics cannot always be implemented by simply customizing properties on a view but must be specifically handled by the code you write. And sometimes that code will only run on devices with very particular hardware architectures. To handle these cases, use conditional compilation.
In previous chapters, you've seen specially formatted comments that tell Delphi to link in resources (for example, {$R *.fmx}
) or to create a console app (for example, {$APPTYPE CONSOLE}
). This same type of syntax is used to include or exclude specific lines of code based on defined constants. These are not code identifiers, which are defined in a const
section, but compilation identifiers...