E2370 Simple type name expected (C++)

From RAD Studio
Jump to: navigation, search

Go Up to Compiler Errors And Warnings (C++) Index

To ensure interoperability between Delphi and C++, there are restrictions on the type names mentioned in the parameter lists of published closure types. The parameter types have to be simple type names with optional const modifier and pointer or reference notation.

So when declaring a closure type, the arguments passed to that closure must be of a simple type. For example, templates are not accepted. To pass a reference to an object of template type to a closure, you must declare a typedef, which counts as a simple type name.

Example:

 #include <System.hpp>

 template <typename T>
 struct SomeTemplateType{ T t; };

 struct TCppTest : public TObject
{
  // Bad
  typedef void __fastcall (__closure *foo1)(SomeTemplateType<int> *);

  // Good
  typedef SomeTemplateType<int> SimpleTypeName;
  typedef void __fastcall (__closure *foo2)(SimpleTypeName *);

  foo1 FProp1;
  foo2 FProp2;
 __published:
  __property foo1 prop1 = { read=FProp1 };  // Error
  __property foo2 prop2 = { read=FProp2 };  // Ok
};