cmake-ide icon indicating copy to clipboard operation
cmake-ide copied to clipboard

c/c++-gcc includes are ignored

Open Compro-Prasad opened this issue 6 years ago • 8 comments

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.

Compro-Prasad avatar Mar 18 '18 03:03 Compro-Prasad

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.

atilaneves avatar Mar 20 '18 11:03 atilaneves

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.

Compro-Prasad avatar Mar 20 '18 14:03 Compro-Prasad

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

Thanks for the kind words!

atilaneves avatar Mar 21 '18 09:03 atilaneves

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.

ppp13 avatar Mar 28 '18 08:03 ppp13

Filtering is probably the best idea.

atilaneves avatar Mar 28 '18 09:03 atilaneves

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

ppp13 avatar Apr 04 '18 14:04 ppp13

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

atilaneves avatar Apr 04 '18 16:04 atilaneves

Just done.

ppp13 avatar Apr 10 '18 15:04 ppp13