Delphi Interface Parameter Handled Differently Now
Go Up to Delphi Interfaces
A Delphi interface parameter with a default value of nil is handled differently beginning with the C++Builder 2010 release. Now, assigning the type void *
to a Delphi interface fails to compile.
The Delphi compiler (DCC32) previously generated the following code in the .hpp file when an interface parameter had the default value of nil:
void methodName(_di_IIntf param = (void *)(0x0));
Previously, the C++ compiler incorrectly accepted this syntax. Beginning with the 2010 release, both the Delphi compiler and the C++ compiler handle this case differently.
The Delphi compiler now emits code like the following in the .hpp file for an interface parameter with a nil default value:
void methodName(_di_IIntf param = _di_IIntf());
The C++ compiler now gives an error for code that assigns the type void *
to a Delphi interface. For instance, the line:
void methodName(_di_IIntf param = (void *)(0x0));
now fails to compile, emitting the error:
Cannot convert 'void *' to '_di_IIntf'M
If you have Delphi code containing an interface parameter with a nil default value, recompile it with DCC32. If you do not have the source, edit the .hpp file and modify all occurrences like this:
void methodName(_di_IIntf param = (void *)(0x0));
to this:
void methodName(_di_IIntf param = _di_IIntf());