`import_type` replacement in IDA9+

Does anyone know how correctly implement replacement of import_type IDA-SDK-API was removed since IDA9?
There are a few approaches below, and no one works as intended.

Hi @bes ,

How about this replacement?

static tinfo_t import_type_from_til(const til_t *src_til, const char *type_name)
{
  tinfo_t tif;
  til_t *idati = get_idati();
  uint32 ord = copy_named_type(idati, src_til, type_name);
  if ( ord != 0 )
    tif.get_numbered_type(idati, ord);
  return tif;
}

Could you let us know if this works for you and meets your expectations?

Hi Teresa,
This works perfect. Thank you.