With --use-c=gcc and --use-analyzer=clang when run “scan-build” it will use include<…> of clang , but we need include<…> of gcc. How can I define the default include path of gcc when I run “scan-build --use-c=gcc --use-analyzer=clang make” ?
This question is related little to scan-build. scan-build calls clang, so if you know how to compile your code with clang and use gcc specific header files, then you got the answer… You shall know, there are compiler specific header files, which you won’t be able to interchange between compilers. Please be more specific with your question which header files you wish to be used. And also, in order to get help, you need to tell more about your setup. (what os? what version of gcc? which clang version? how clang got compiled? etc…)
The scan-build tool should be using the original compiler for compiling (transparently) and clang for analysis (inevitably). It means that both compilers need to compile the code independently (even though the clang instance that is used for analysis doesn't produce any binaries, all earlier phases of compilation need to occur), which means they need to find all includes. It also means that if a certain translation unit cannot be compiled with clang (with relevantly interposed compilation flags), it cannot be analyzed.
So i'd second the question regarding which includes you're having problems with.
Thank you for answering my email. The cmd we use is “scan-build --use-analyzer=/home/clang/bin/clang --use-cc=/home/gcc/arm-none-eabi/bin/arm-none-eabi-gcc --analyzer-target=arm-linux-gnueabi make -s MMU=2 products_isp=hi6250 -j”
The version of clang is 3.8.256229 and gcc is 4.7.1 and os is Ubuntu 12.04
The error log of clang is :
In file include from /usr/include/math.h/usr/include/bits/matchcalls.h:110:1 error expected identifier or “(”
these information are still not enough to help you out. So, I only can guess what you have or trying to achieve… As I suggested earlier, try to compile your project with Clang as a first step. If you done that, scan-build won’t be an issue… As far as I can see, you have a cross-compiler gcc and a native clang compiler. (Is this correct?) You might want to look at these pages: https://clang.llvm.org/docs/CrossCompilation.html http://llvm.org/docs/HowToCrossCompileLLVM.html