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

c/c++-gcc includes are ignored #161

Open
Compro-Prasad opened this issue Mar 18, 2018 · 8 comments
Open

c/c++-gcc includes are ignored #161

Compro-Prasad opened this issue Mar 18, 2018 · 8 comments

Comments

@Compro-Prasad
Copy link

I just installed cmake-ide and did the setup as mentioned. It only added clang include directories for flycheck. But I am using the c/c++-gcc checker.

@atilaneves
Copy link
Owner

Either the c/c++-gcc checker didn't exist when I wrote cmake-ide or I just didn't know about it. I added code to set the equivalent gcc flycheck variables. I don't know whether it works other than the unit tests pass - I don't have that checker installed.

@Compro-Prasad
Copy link
Author

Will try out the update but as far as I know you can see other checkers using C-c ! C-c. Press tab if not using a completion framework like helm. It might work.
There I have seen c/c++-cppcheck also. See if you can include that too.
And I am amused by the way it handles everything. Great software.

@atilaneves
Copy link
Owner

I knew about using cppcheck, that's been in cmake-ide for a while.

Thanks for the kind words!

@ppp13
Copy link
Contributor

ppp13 commented Mar 28, 2018

I just tried this cmake-ide enhancement for c/c++-gcc, but I get the following message when the checker is run:

Suspicious state from syntax checker c/c++-gcc: Flycheck checker c/c++-gcc returned non-zero exit code 1, but its output contained no errors: cc1plus: error: output filename specified twice

I suppose the reason is that the flycheck is already defining the c/c++-gcc checker with an explicit output option -S -o /dev/null for gcc in the flycheck.el file (while it is not doing this for c/c++-clang):
(flycheck-define-checker c/c++-gcc
"A C/C++ syntax checker using GCC.
Requires GCC 4.4 or newer. See URL 'https://gcc.gnu.org/'."
:command ("gcc"
"-fshow-column"
"-iquote" (eval (flycheck-c/c++-quoted-include-directory))
(option "-std=" flycheck-gcc-language-standard concat)
(option-flag "-pedantic" flycheck-gcc-pedantic)
(option-flag "-pedantic-errors" flycheck-gcc-pedantic-errors)
(option-flag "-fno-exceptions" flycheck-gcc-no-exceptions)
(option-flag "-fno-rtti" flycheck-gcc-no-rtti)
(option-flag "-fopenmp" flycheck-gcc-openmp)
(option-list "-include" flycheck-gcc-includes)
(option-list "-W" flycheck-gcc-warnings concat)
(option-list "-D" flycheck-gcc-definitions concat)
(option-list "-I" flycheck-gcc-include-path)
(eval flycheck-gcc-args)
"-x" (eval
(pcase major-mode
(c++-mode "c++")
(c-mode "c")))
;; GCC performs full checking only when actually compiling, so
;; -fsyntax-only' is not enough. Just let it generate assembly
;; code.
"-S" "-o" null-device
;; Read from standard input
"-")
and cmake-ide is adding an additional -o through flycheck-gcc-args.
e.g. in my case the offending invocation is:
c/c++-gcc (-fshow-column -iquote /home/user/workspace/prob_ml/src/ -std=c++14 -Wall -Wextra -Dprob_ml_EXPORTS -I /usr/local/include -I /home/user/workspace/prob_ml/src -pipe -m64 -fsigned-char -fPIC -pthread -g -fPIC -o CMakeFiles/prob_ml.dir/src/readMNIST.cpp.o -c -x c++ -S -o /dev/null -)

I am not sure regarding the best approach should be to solve this, i.e. either filtering out -o CMakeFiles/prob_ml.dir/src/readMNIST.cpp.o from flycheck-gcc-args (cmake-ide self contained), or asking flycheck for a smarter definition of c/c++-gcc.

@atilaneves atilaneves reopened this Mar 28, 2018
@atilaneves
Copy link
Owner

Filtering is probably the best idea.

@ppp13
Copy link
Contributor

ppp13 commented Apr 4, 2018

Please find a possible quick patch attached. I just added a cmake-ide--filter-output-arg function.

0001-Remove-the-gcc-o-argument-for-the-flycheck-c-c-gcc-c.patch.gz

@atilaneves
Copy link
Owner

@ppp13 If you have a patch, please submit a PR.

@ppp13
Copy link
Contributor

ppp13 commented Apr 10, 2018

Just done.

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

3 participants