问题描述
我正在使用“clang 版本 3.9.0 (branches/release_39)”。我正在尝试获取声明为的数组的确切数组元素类型:
struct mystruct {
uint32_t myarray[2];
};
clang_visitChildren(
cursor,[](CXCursor cursor,CXCursor parent,CXClientData client_data)
{
CXType type = clang_getCursorType(cursor);
CXCursorKind kind = clang_getCursorKind(cursor);
switch (kind)
{
case CXCursorKind::CXCursor_FieldDecl:
{
if (type.kind == CXTypeKind::CXType_ConstantArray) {
auto arrElementType = clang_getArrayElementType(type);
auto typeSpelling = clang_getCString(clang_getTypeKindSpelling(arrElementType.kind));
....
我得到 typeSpelling 为“Int”而不是“uint32_t”。如果我将数组类型更改为“uint8_t”,我仍然会得到“Int”。那么如何获得确切的类型或至少为每个元素(32 或 8)分配的位数?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)