我在 Clang 3.4 中遇到了一个相当棘手的编译问题。该代码在 Clang 3.2 上编译得很好,但我想尝试一些仅在 Clang 3.4 上发现的前沿特性。
我按照此处的说明安装了 Clang 3.4 。
有没有人知道为什么 Clang 抱怨 stdlib.h?我正在使用 Lubuntu 13.04。
Clang 3.2 的输出 -
clang -v -g -fsanitize=address -fno-omit-frame-pointer -fms-extensions -O0 -o obj/Test.o -Iinc/ -c Test.c
Ubuntu clang version 3.2-1~exp9ubuntu1 (tags/RELEASE_32/final) (based on LLVM 3.2)
Target: i386-pc-linux-gnu
Thread model: posix
"/usr/bin/clang" -cc1 -triple i386-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name Test.c -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -fuse-init-array -target-cpu pentium4 -target-linker-version 2.23.2 -momit-leaf-frame-pointer -v -g -coverage-file /home/adminuser/project/obj/Test.o -resource-dir /usr/bin/../lib/clang/3.2 -I inc/ -fmodule-cache-path /var/tmp/clang-module-cache -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/clang/3.2/include -internal-isystem /usr/include/clang/3.2/include/ -internal-externc-isystem /usr/include/i386-linux-gnu -internal-externc-isystem /usr/include/i686-linux-gnu -internal-externc-isystem /usr/include -O0 -fdebug-compilation-dir /home/adminuser/project -ferror-limit 19 -fmessage-length 0 -fsanitize=address -mstackrealign -fms-extensions -fmsc-version=1300 -fobjc-runtime=gcc -fdiagnostics-show-option -o obj/Test.o -x c Test.c
clang -cc1 version 3.2 based upon LLVM 3.2svn default target i386-pc-linux-gnu
ignoring nonexistent directory "/usr/bin/../lib/clang/3.2/include"
ignoring nonexistent directory "/usr/include/i686-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
inc
/usr/local/include
/usr/include/clang/3.2/include
/usr/include/i386-linux-gnu
/usr/include
Clang 3.4 的输出 -
clang -v -g -fsanitize=address -fno-omit-frame-pointer -fms-extensions -O0 -o obj/Test.o -Iinc/ Test.c
Ubuntu clang version 3.4-1~exp1 (trunk) (based on LLVM 3.4)
Target: i386-pc-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/4.7
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/4.7.3
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/4.8
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/4.8.1
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.7
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.7.3
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8.1
Selected GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8
"/usr/bin/clang" -cc1 -triple i386-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name Test.c -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -fuse-init-array -target-cpu pentium4 -target-linker-version 2.23.2 -v -g -coverage-file /home/adminuser/project/obj/Test.o -resource-dir /usr/bin/../lib/clang/3.4 -I inc/ -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/clang/3.4/include -internal-isystem /usr/include/clang/3.4/include/ -internal-externc-isystem /usr/include/i386-linux-gnu -internal-externc-isystem /usr/include/i686-linux-gnu -internal-externc-isystem /usr/include -O0 -fdebug-compilation-dir /home/adminuser/BuildFW/test/GlassCubeAssembler_C -ferror-limit 19 -fmessage-length 0 -fsanitize=address,init-order -mstackrealign -fms-extensions -fmsc-version=1300 -fobjc-runtime=gcc -fobjc-default-synthesize-properties -fdiagnostics-show-option -vectorize-slp -o obj/Test.o -x c Test.c
clang -cc1 version 3.4 based upon LLVM 3.4 default target i386-pc-linux-gnu
ignoring nonexistent directory "/usr/bin/../lib/clang/3.4/include"
ignoring nonexistent directory "/usr/include/i686-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
inc
/usr/local/include
/usr/include/clang/3.4/include
/usr/include/i386-linux-gnu
/usr/include
End of search list.
In file included from Test.c:4:
/usr/include/stdlib.h:69:23: error: expected member name or ';' after declaration specifiers
union wait *__uptr;
~~~~~ ^
1 error generated.