Micro-ISV.asia

Friday, 17 September 2010

$STRINGCHECKS Gone in Delphi XE

Filed under: Programming — Jan Goyvaerts @ 8:10

Delphi 2009 was the first Delphi version to produce Unicode applications. When it was released I ranted about the needless strings checks that it did. Those were a bit of a hack to allow C++Builder developers to port their applications to Unicode more easily by fixing up at runtime what the developer failed to fix at coding time. The checks provided no benefits to Delphi developers. This did not change in Delphi 2010.

Delphi XE no longer does these strings checks. The functions that performed them, such as InternalUStrFromLStr, have been removed from System.pas. The Project Options screen no longer offers the “string format checking” compiler option. The compiler still accepts the $STRINGCHECKS directive as valid syntax, but it no longer has any effect. Even if you put {$STRINGCHECKS ON} in your units, the compiler generates the “quick and efficient” code I showed in my Delphi 2009 article.

The main upshot is that the RTL and VCL in Delphi XE no longer do those needless string checks. Thought you can and should use {$STRINGCHECKS OFF} to compile your own units in Delphi 2009 and 2010 without the string checks, the units in the RTL and VCL in Delphi 2009 and 2010 always do the string checks as Embarcadero compiled them with {$STRINGCHECKS ON}.

1 Comment

  1. You’re not the only one that ranted on $STRINGCHECKS.
    See:
    http://andy.jgknet.de/blog/2009/07/why-i-hate-cbuilder-2009/
    http://andy.jgknet.de/blog/2009/02/performance-tip-lengthstring-and-strindex-in-delphi-2009/

    Those checks were really annoying for those looking to write tight code.

    Comment by Fabricio — Friday, 3 December 2010 @ 0:07

Sorry, the comment form is closed at this time.