How can I best maintain compatibility for namespaces in uses between Delphi 7 to Delphi XE7 ?
Delphi 7 use SysUtils while Delphi XE7 use System.SysUtils.
It clutter the code a lot with many ifdefs, so I want to avoid it if possible.
How can I best maintain compatibility for namespaces in uses between Delphi 7 to Delphi XE7 ?
Delphi 7 use SysUtils while Delphi XE7 use System.SysUtils.
It clutter the code a lot with many ifdefs, so I want to avoid it if possible.
In the later versions of Delphi which support namespace prefixes (I believe that's XE2 and up), you can define the namespaces in the project options.
Project Options > Delphi Compiler > Unit scope names
Then, you won't need to include those prefixes in your uses clause.
By default, new projects will automatically include most of these for you. However if you're upgrading an old project, especially a package, these might not be populated by default. I've had an incident where randomly Delphi started failing to compile because these units were missing their namespace prefixes.
© 2022 - 2024 — McMap. All rights reserved.