提供: tty00
(ページの作成:「Category:clang」) |
|||
| 行1: | 行1: | ||
| + | == 使い方 == | ||
| + | <source lang=python> | ||
| + | import clang.cindex | ||
| + | index = clang.cindex.Index.create() | ||
| + | translation_unit = index.parse('source_code.c') #TranslationUnitクラスからASTにアクセスする | ||
| + | </source> | ||
| + | |||
| + | == LibclangError例外の対処方法 == | ||
| + | *例外メッセージ | ||
| + | <pre> | ||
| + | LibclangError: libclang-3.5.so: cannot open shared object file: | ||
| + | No such file or directory. To provide a path to libclang use Config.set_library_path() or Config.set_library_file(). | ||
| + | </pre> | ||
| + | |||
| + | *対処方法 | ||
| + | Configを使用しlibclangのパスを指定する | ||
| + | |||
| + | <source lang=python> | ||
| + | Config.set_library_path('/usr/lib/llvm-3.5/lib/') | ||
| + | Config.set_library_file('/usr/lib/llvm-3.5/lib/libclang.so.1') | ||
| + | </source> | ||
| + | |||
| + | |||
[[Category:clang]] | [[Category:clang]] | ||
2014年4月28日 (月) 22:13時点における最新版
使い方
import clang.cindex index = clang.cindex.Index.create() translation_unit = index.parse('source_code.c') #TranslationUnitクラスからASTにアクセスする
LibclangError例外の対処方法
- 例外メッセージ
LibclangError: libclang-3.5.so: cannot open shared object file: No such file or directory. To provide a path to libclang use Config.set_library_path() or Config.set_library_file().
- 対処方法
Configを使用しlibclangのパスを指定する
Config.set_library_path('/usr/lib/llvm-3.5/lib/') Config.set_library_file('/usr/lib/llvm-3.5/lib/libclang.so.1')