在Eclipse中的Autotools项目中使用clang ++进行代码分析 [英] Using clang++ for code analysis in an Autotools project in Eclipse

查看:253
本文介绍了在Eclipse中的Autotools项目中使用clang ++进行代码分析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Mac OS 10.8上使用Eclipse 4.2,安装了命令行工具(Xcode 4.6.3)。 clang编译器通过使用以下标志符支持C ++ 11: -std = c ++ 11 -stdlib = libc ++



我在Eclipse中有一个Autotools管理的项目。在配置之后覆盖 CXX CXXFLAFGS 环境变量后, $ c>被调用。然而,Eclipse中的静态代码分析继续使用GCC(与Xcode一起安装的版本是GCC 4.2),因此不支持C ++ 11,并且许多行显示不是真实的错误,使得静态代码分析几乎没用。



使用homebrew我也安装了GCC 4.7,但我没有成功让Eclipse使用那个版本(或clang ++)来执行静态代码分析。 >

当使用Autotools管理的项目时,是否可以使Eclipse使用不同的编译器进行静态代码分析?在安装Xcode 5之后,按照 stackoverflow.com/questions/13635079/enable-c11-in-eclipse-cdt-juno-kepler-indexer\">这个问题,我设法解决这个问题(我不能再测试这是否适用于Xcode 4.6太)。



解决方案是转到项目属性 - > C / C ++常规 - > 预处理器包括路径,宏等 - > 提供者 - > CDT GCC内置编译器设置命令获取编译器规格: append -std = c ++ 11 -stdlib = libc ++



执行此更改后,该行应如下所示:


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


< blockquote>

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?

解决方案

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++

这篇关于在Eclipse中的Autotools项目中使用clang ++进行代码分析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆