Jump to content

Henrick Wibell Hellström

Members
  • Content Count

    3
  • Joined

  • Last visited

Community Reputation

0 Neutral
  1. Henrick Wibell Hellström

    Delphi method overload compatibility with C++ Win64 Modern

    Indeed, yes, but it would cause ripple effects in the Delphi code, if ObjectIdentifier variables are passed to Format calls or Exception constructors. In Delphi, records with operator overloads can't be passed as elements of variant array arguments. Not even if they implement a suitable Implicit operator. Changing the declaration from 'type AnsiString' to a record, would also entail a complete rewrite of any constant declaration in the following form: const cAttrValueIdentifiers: array [0..1] of ObjectIdentifier = ( '2.5.4.41', // id-at-name '2.5.4.4' // id-at-surname ); to: const cAttrValueIdentifiers: array [0..1] of ObjectIdentifier = ( (fData: '2.5.4.41'), // id-at-name (fData: '2.5.4.4') // id-at-surname ); If there are several hundreds such constants, and it is critical that each is correct, it is not something you could entrust a Delphi IDE recordable macro. Granted, you could change the type of the constants to array [] of AnsiString, but that would entail a lack of clarity.
  2. Henrick Wibell Hellström

    Delphi method overload compatibility with C++ Win64 Modern

    Thank you for your insights. Do you have any good idea for a workaround? I suppose you can use {$NODEFINE TFoo} to leave the entire class out of the hpp file, or add a 'dummy' parameter at the end of either overloaded Bar method, but neither solutions strikes me as examples of good coding.
  3. I apologize if this question has been posted before, but as far as I can tell, this should be a relatively new compatibility issue. It concerns using Delphi components in a RAD Studio 12 C++ Win64 Modern project. I am interested in known workarounds. For as long as I remember, it has been possible to write code like this: type ObjectIdentifier = type AnsiString; TFoo = class procedure Bar(const Value: AnsiString); overload; procedure Bar(const Value: ObjectIdentifier); overload; end; By using the keyword "type" in the declaration of ObjectIdentifier, it becomes a new type, and not just another name for the same type. Furthermore, it only matters in parameter declarations, such as this. You are free to assign AnsiString values to variables and parameters of the declared type, and vice versa, except when it comes to method overloading and operator overloading. The problem is that this seems to be broken in version 12 C++ Win64 Modern. If you output a hpp file corresponding to the above declarations, there will be a compiler error indicating that the Bar methods have identical parameters. Earlier C++ compilers have not had a problem with this. Is anyone aware of an optimal work around?
×