cppast icon indicating copy to clipboard operation
cppast copied to clipboard

typedef with build-in type is not working

Open littleGnAl opened this issue 3 years ago • 1 comments

  • cppast version: latest one
  • parser: libclang_parser
  • clang version: 13.0.1

Explanation of the error.

Input:

typedef const char* user_id_t;
typedef void* view_t;

My code is like below, but I can't get any output of the user_id_t and view_t

  if (e.kind() == cppast::cpp_entity_kind::type_alias_t)
  {
      auto &cpp_type_alias = static_cast<const cppast::cpp_type_alias &>(e);
      std::cout << "type name" << cpp_type_alias.name() << ", under type: " << cpp_type_alias.underlying_type.name() << std::endl;
  }

littleGnAl avatar Jul 26 '22 08:07 littleGnAl

Your code doesn't compile, underlying_type is a method and cpp_type has no .name(). Can you please post the exact code you're using?

foonathan avatar Jul 31 '22 10:07 foonathan

Thanks for the response @foonathan , it seems I made some mistakes, it works fine now.

littleGnAl avatar Aug 15 '22 14:08 littleGnAl