Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Namespace compatibility in VCL for Delphi

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.

like image 290
Roland Bengtsson Avatar asked Mar 22 '15 17:03

Roland Bengtsson


1 Answers

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.

like image 107
Jerry Dodge Avatar answered Oct 24 '22 19:10

Jerry Dodge