It's because that clang_getClangVersion interface return type is not c_char_p but CXString. Below is my modify:
class CXString(ctypes.Structure):
_fields_ = [
('data', ctypes.POINTER(None)),
('private_flags', ctypes.c_uint32),
]
def clang_version():
"""Pull the clang C library version from the API"""
# avoid loading the cindex API (cindex.conf.lib) to avoid version conflicts
get_version = cindex.conf.get_cindex_library().clang_getClangVersion
get_version.restype = CXString
version_string = get_version()
version_string = ctypes.cast(version_string.data, ctypes.c_char_p).value
version = 'Unknown'
if version_string and len(version_string) > 0:
version_groups = re.match(br'.+version ((\d+\.)?(\d+\.)?(\*|\d+))', version_string)
if version_groups and len(version_groups.groups()) > 0:
version = version_groups.group(1).decode()
return version
It's because that clang_getClangVersion interface return type is not c_char_p but CXString. Below is my modify: