Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solve windows clang-17.0.6 get_version() access violation exception #136

Open
huhutm opened this issue Jul 18, 2024 · 0 comments
Open

solve windows clang-17.0.6 get_version() access violation exception #136

huhutm opened this issue Jul 18, 2024 · 0 comments

Comments

@huhutm
Copy link

huhutm commented Jul 18, 2024

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
@huhutm huhutm changed the title solve windows clang-157.0.6 get_version() access violation exception solve windows clang-17.0.6 get_version() access violation exception Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant