Is there a way to conditionally compile part of Delphi code in Delphi only (but not in C++Builder)?
Rationale:
OmniThreadLibrary contains overloaded properties in type TOmniValue
.
property AsArrayItem[idx: integer]: TOmniValue
read GetAsArrayItem write SetAsArrayItem; default;
property AsArrayItem[const name: string]: TOmniValue
read GetAsArrayItem write SetAsArrayItem; default;
This concept does not translate to C++. (IOW, if you try to compile this code with C++Builder, compilation fails.)
One way to solve the problem is to rename one of the properties and remove the default
specifier from it.
property AsArrayItem[idx: integer]: TOmniValue
read GetAsArrayItem write SetAsArrayItem; default;
property AsArrayItemByName[const name: string]: TOmniValue
read GetAsArrayItemByName write SetAsArrayItemByName;
This way, however, is not backwards compatible and users of the library would have to change the source code that was using the [string]
version of this default property.
I would like to keep the code backwards compatible and make it work in C++Builder. My idea was to do something like this
property AsArrayItem[idx: integer]: TOmniValue
read GetAsArrayItem write SetAsArrayItem; default;
{$IF CompilingInDelphi}
property AsArrayItem[const name: string]: TOmniValue
read GetAsArrayItem write SetAsArrayItem; default;
{$ELSEIF CompilingInC++Builder}
property AsArrayItemByName[const name: string]: TOmniValue
read GetAsArrayItemByName write SetAsArrayItemByName;
{$IFEND}
but it looks like there is no useful symbol that could be used for such conditional compilation.