Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <clang-c/Index.h>
- int main(int argc, char *argv[])
- {
- CXIndex index;
- CXTranslationUnit tu;
- CXFile file;
- CXSourceLocation loc;
- CXCursor cursor, def;
- CXType type;
- CXString typesp;
- const char *types;
- char const *args[2] = {"-x", "c++"};
- index = clang_createIndex(0, 0);
- tu = clang_createTranslationUnitFromSourceFile(index, argv[1],
- 2, args, 0, NULL);
- file = clang_getFile(tu, argv[1]);
- loc = clang_getLocation(tu, file, atoi(argv[2]), atoi(argv[3]));
- cursor = clang_getCursor(tu, loc);
- if (clang_isPreprocessing(cursor.kind))
- printf("Preprocessorn");
- else {
- def = clang_getCursorDefinition(cursor);
- if (clang_Cursor_isNull(def))
- type = clang_getCursorType(cursor);
- else
- type = clang_getCursorType(def);
- typesp = clang_getTypeSpelling(type);
- types = clang_getCString(typesp);
- printf("%sn", types);
- clang_disposeString(typesp);
- }
- clang_disposeTranslationUnit(tu);
- clang_disposeIndex(index);
- }
- #include <iostream>
- int main()
- {
- long t;
- t = 0;
- std::cout << "Hello World!";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement