Using clang++ for code analysis in an Autotools project in Eclipse

夙愿已清 提交于 2019-12-02 08:23:52

问题


I am using Eclipse 4.2 on Mac OS 10.8, with the command line tools (Xcode 4.6.3) installed. The clang compiler supports C++11 by means of using the following flags: -std=c++11 -stdlib=libc++.

I have an Autotools-managed project in Eclipse. Real compilation works as expected after overriding CXX and CXXFLAFGS environment variables when configure is called. However, the static code analysis in Eclipse continues to use GCC (the version installed with Xcode is GCC 4.2), so there is no support for C++11, and lots of lines display errors that are not real ones, making static code analysis almost useless.

Using homebrew I also installed GCC 4.7, but I have not succeeded to make Eclipse use that version (or clang++) for performing static code analysis.

Is it possible, when using an Autotools-managed project, to make Eclipse use a different compiler for the static code analysis? Where should I specify that?


回答1:


After installing Xcode 5, and following the directions in this question, I managed to solve the problem (I cannot test anymore whether this applies to Xcode 4.6 too).

The solution is to go to Project properties -> C/C++ General -> Preprocessor Include Paths, Macros etc. -> Providers -> CDT GCC Built-in Compiler Settings, and in Command to get compiler specs: append -std=c++11 -stdlib=libc++.

After doing that change, the line should look like:

${COMMAND} -E -P -v -dD ${INPUTS} -std=c++11 -stdlib=libc++



来源:https://stackoverflow.com/questions/18086835/using-clang-for-code-analysis-in-an-autotools-project-in-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!