4 ms·
It makes sense to write system APIs in C, but there are many more things than system APIs, and many of them find it useful to use C++ constructs. (edit) Clang'
by mountain_lion 9y ago
It makes sense to write system APIs in C, but there are many more things than system APIs, and many of them find it useful to use C++ constructs.
(edit) Clang's internals are also several orders of magnitude easier to work with than GCC's internals. In fact, clang is designed to be used as a library, and CLIF leverages that very, very highly.
See, for example, https://clang.llvm.org/docs/ClangTools.html https://clang.llvm.org/docs/ClangTools.html . Clang tools are very powerful, and much of CLIF is based on a Clang tool, not a GCC internals hack.
- chubot 9y agoHow stable are Clang's internals? Are you supposed to be able to write your own Clang tools and link them dynamically, or are they mostly distributed and built together with the Clang source code? (i.e. like Linux drivers where there is no stable interface.) I know that LLVM is notable for not maintaining API stability -- not sure about Clang.
- mountain_lion 9y agoThere are (roughly) two ways of using Clang as a library. The first is a via a C-based API into a libclang.so. This is an API designed to be extremely stable, is fairly powerful, and works relatively well. That API doesn't expose absolutely everything though, which is one reason it can be so stable. Tools that need more are typically shipped and built along side the clang source code. CLIF is the latter. You can read about both of them here: http://clang.llvm.org/docs/Tooling.html http://clang.llvm.org/docs/Tooling.html
- pjmlp 9y agoAlso should be noted that outside UNIX world, there are other OSes that don't use C conventions, or are migrating away from them (even if slowly).