One of the features that bites me over and over again is the ZEROBASEDSTRINGS that got introduced in Delphi XE3 and is by default ON in mobile compilers and OFF in Desktop compilers.
Back then, Mark Edington showed a small example of the effects:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
The XE3 RTL source code has been refactored to be string index base agnostic. In most cases this is done by utilizing string helper functions which are always zero based.
When it is necessary to traverse a string, the Char[] property is often used to access the individual characters without concern for the current state of the compiler with respect to zero based strings.
In addition, the “Low” and “High” standard functions can now be passed a string variable to provide further flexibility as needed.
When zero based strings are enabled, Low(string) will return 0, otherwise it will return 1. Likewise, High() returns a bounds adjusted length variation.
The problem is the non-existent forward compatibility of the other compilers (Delphi XE2 and lower).
So if you have library code that needs to work in Delphi versions, you cannot use the High and Low to make the code ZEROBASEDSTRINGS neutral.
Many Delphi developers regularly skip many Delphi versions, so these are still popular:
Delphi XE1 and XE2 (the last 2 compilers before Delphi really started to support mobile)
Delphi 2007 (the last non-Unicode Delphi compiler)
Delphi 7 (the last non-Galileo IDE)
The result is that library code is full of conditionan IF/IFDEF blocks like these:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
type can print UTF-16LE files with a BOM regardless of your current codepage
Win32 programs can be programmed to output Unicode to the console, using WriteConsoleW.
Other programs which set the codepage and adjust their output encoding accordingly can print Unicode on the console regardless of what the codepage was when the program started
For everything else you will have to mess around with chcp, and will probably still get weird output.
I’ve been experimenting with the Delphi hinting directives lately to make it easier to migrate some libraries to newer versions of Delphi and newer platforms.
Up to Delphi 5 you didn’t have any means to declare code obsolete. You had to find clever ways around it.
Warnings for hinting directives
When referring to identifiers marked with a hinting directive, you can get various warning messages that depend on the kind of identifier: unit, or other symbol. Read the rest of this entry »
A while ago, I was working with a not so cooperative corporate firewall. All web browsers would work fine, but most other applications would not go through the proxy in a nice way.
For instance, DropBox would show the dreadfull “Connection Error” dialog shown on the right.
That dialog basically means “Dropbox has no clue what happens, try fiddling with your proxy or account settings, then press Reconnect Now” to retry.
Many other applications had issues (for instance Visual Studio connecting to Team Foundation System was very unreliable and the workarounds clumsy).
So I fired up my old buddy [WayBack] Fiddler 2 HTTP debugging proxy.
Further on, you will learn that Fiddler2 is much more, but right now it is enough to know that it basically sits as a local proxy between your applications and the outside world. Read the rest of this entry »
A while ago, I had to disable a couple of warnings from legacy code so I could first perform the Unicode conversion, then make time to eliminate the actual warning cause.
He lists all the W#### and X#### warnings he could find in Delphi XE2 (XE3, XE4 and XE5 more or less have the same), including the mapping to the equivalent directive IDs used inside these blocks: