clang
Version, currently 0.2.03 versions
- 0.3.0latestJul 1, 2019
- 0.2.0not indexedJul 2, 2026
- 0.1.0not indexedJul 2, 2026
github.com/crystal-lang/clang.cr
Bindings for libclang
52 stars
2 dependents
License: Apache-2.0
Nothing has been indexed for 0.2.0 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
clang:
github: crystal-lang/clang.cr
version: ~> 0.2.0Then run:
shards installshard.yml
No shard.yml has been indexed for 0.2.0. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
# libclang bindings for Crystal
Usage:
```crystal
require "clang"
index = Clang::Index.new
files = [
#Clang::UnsavedFile.new("input.c", "#include <pcre.h>\n"),
Clang::UnsavedFile.new("input.c", "#include <clang/Basic/ABI.h>\n"),
]
tu = Clang::TranslationUnit.from_source(index, files, [
"-I/usr/include",
"-I/usr/lib/llvm-5.0/include",
])
tu.cursor.visit_children do |cursor|
p cursor
Clang::ChildVisitResult::Continue
end
```
## Samples
See the `samples` folder for some example usages:
- `samples/debug.cr` will print the AST of C or C++ headers as they are parsed;
- `samples/c2cr.cr` will automatically generate Crystal bindings for a C header.
For example:
```sh
$ shards build --release
$ bin/c2cr -I/usr/lib/llvm-5.0/include llvm-c/Core.h \
--remove-enum-prefix=LLVM --remove-enum-suffix > llvm-c/Core.cr
$ bin/c2cr -I/usr/lib/llvm-5.0/include clang-c/Index.h \
--remove-enum-prefix > clang-c/Index.cr
$ bin/c2cr gtk-2.0/gtk/gtkenums.h --remove-enum-prefix > gtk/enums.cr
```
## Reference
- [C interface to Clang](http://clang.llvm.org/doxygen/group__CINDEX.html)
## License
Distributed under the Apache 2.0 license.
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.2.0- Tagged
- Jul 2, 2026
- Commit
bedf13d11a87- Indexed
- not yet
Dependents
Repository
github.com/crystal-lang/clang.cr
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 12, 2026
- Synced
- Aug 12, 2026
- Versions
- 3