Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not passing -std=c++11 to flycheck #9

Closed
erreina opened this issue Dec 23, 2014 · 2 comments
Closed

Not passing -std=c++11 to flycheck #9

erreina opened this issue Dec 23, 2014 · 2 comments

Comments

@erreina
Copy link

erreina commented Dec 23, 2014

I am using cmake-ide in a c++11 project and flycheck is giving me lots of errors. I run flycheck-compile with c/c++-clang and I was able to see that the argument -std=c++11 was missing. I copied the exact line and executed from the console passing this parameter and it reported no errors. I review a little the code of cmake-ide and I found that the only parameters that are captured are the includes -I, -include, -isystem and the definitions -D. I think that there are lots of other parameters that are importan to pass to the compiler such us: -std, the -f* and the -W*.

@erreina
Copy link
Author

erreina commented Dec 23, 2014

I fould that in order to flycheck pass that argument to clang it is necessary to put in the variable flycheck-clang-language-standard the value c++11. I think cmake-ide should do that for us.

@atilaneves
Copy link
Owner

It does, in a way. Since there's no way to know what flags users need in totality, and the fact that system headers are in different locations, all flags you want to include should be specified in cmake-ide-flags-c++ and cmake-ide-flags-c variables. For instance, I personally use -std=c++1y instead of c++11, how would cmake-ide know which one to use?
Here's what I have in my own init.el:

(cmake-ide-setup)
(setq cmake-ide-flags-c++ (append '("-std=c++1y")
                                 (mapcar (lambda (path) (concat "-I" path)) (c++-include-paths))))
(setq cmake-ide-flags-c '("-I/usr/include"))

The c++-include-paths function calls gcc -v -xc++ /dev/null -fsyntax-only and massages the result in elisp. Those -I flags must be set in the aforementioned cmake-ide variables for autocompletion to work correctly. It's explained in the README under "Usage".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants