GCC

C++ 中的 main 定义

| Development | #C++ | #C | #Programming | #Linkage | #GCC | #LLVM

新的 C++ 标准中 不允许给 main 指定 linkage-specification 了。

当然,考虑到原本 main() 也是 C 运行环境在开始运行程序的时候调用的, 而 C 运行环境自然也预期 C linkage,即不按照 C++ 的习惯对符号根据参数增加名字前缀, 因此大部分编译器在遇到 C++ 程序定义全局 main() 的时候也会按照习惯采取 C linkage 方式去翻译。这一规则首先被 GCC 采纳,随后 LLVM 也跟进了。

阅读全文…( 本文约 389 字,阅读大致需要 1 分钟 )

Progress on LLVM clang

| *nix and Win32 Kernel | #clang | #FreeBSD | #gcc | #llvm

As some of you already know, FreeBSD, along with some other Open Source projects, is moving away from GCC due to GPLv3. From a technology perspective, this also makes sense since the (likely) candidate, BSD-style licensed, LLVM based clang, a C compiler, is making reasonably good progress.

So, what should we expect from LLVM or clang?

Here is a good comparison between GCC and clang. Despite GCC is popular, considerably more mature, and supports more languages (especially C++, which clang’s support is incomplete at this moment), clang provides cleaner AST (Abstract Syntax Tree), much more modularized (if you take a look at GCC’s history, Richard Stallman intentionally made GCC’s code not reusable in other software), provided much more information for optimizer, is much faster and use much less memory, etc.

For FreeBSD, currently, clang can compile its kernel with only very few tweaks.

阅读全文…( 本文约 315 字,阅读大致需要 2 分钟 )