1

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?

betabandido
  • 18,946
  • 11
  • 62
  • 76
  • Hmm, interesting. I've always thought that the static analysis is done by Codan, see for example [C++, Eclipse CDT code analysis?](http://stackoverflow.com/q/5540751/341970) How do you know that the static analysis is done by gcc in your case? (I am using Linux.) – Ali Aug 06 '13 at 19:54
  • @Ali I'm not totally sure how the actual check is done, but I guess in that case, Codan still needs to look for the include headers. And those shouldn't be the ones included in GCC 4.2 (Xcode 4.6.3), but either Clang's ones or the ones included in GCC 4.7 (via homebrew). – betabandido Aug 06 '13 at 20:07
  • Yes, that makes sense. If it is any consolation, the static analysis still doesn't work well with C++11 (or C++98 for that matter, despite my bug report). It is the first thing I set in Eclipse, I switch off the static analysis... :( – Ali Aug 06 '13 at 20:13
  • @Ali I managed to solve the issue :) – betabandido Sep 19 '13 at 01:03
  • Thanks for letting me know about it. I don't understand why this helps you but I am glad it does. My line already looks like what your write, yet, static analysis fails. :( – Ali Sep 19 '13 at 22:53
  • @Ali Have you installed Xcode 5? As far as I know, in that version, GCC has been completely replaced by Clang, which includes C++11 support. – betabandido Sep 20 '13 at 01:18

1 Answers1

0

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

Community
  • 1
  • 1
betabandido
  • 18,946
  • 11
  • 62
  • 76