Sarcasm / flycheck-irony

C, C++ and Objective-C support for Flycheck, using Irony Mode
56 stars 10 forks source link

Flycheck Reports Incorrect Errors when compilation database is in separate build path #8

Closed russellmcc closed 9 years ago

russellmcc commented 9 years ago

I'm using ninja for a project, and I'm trying to get flycheck-irony working. It's looking really good so far, except for some strange problems with header files.

Here's my project layout:

This is the preferred layout for the ninja build tool. I generated compile_commands.json using ninja.

Since the compile_commands.json is in a separate build directory and not directly in the source directory or a parent, irony-cdb doesn't find it automatically. To add it, I used irony-cdb-json-add-compile-commands-path, I set the project root to "root", and the compile_commands.json appropriately.

It seems like the cdb-json-projects file is correct:

cat ~/.emacs.d/irony/cdb-json-projects 
;; -*- emacs-lisp -*-
;;
;; JSON Compilation Database project list.
;;
;; File auto-generated by irony-cdb-json.
;;
(("<root>" . "<root>/out/Default/compile_commands.json"))

I ran the check-compile-options function that you provided here, output from the header file was:

I: found compilation database: <root>/out/Default/compile_commands.json
I: found by guessing: (((-MMD -MF obj/src/CoreAudioSDK/foo.CAStreamBasicDescription.o.d -I../../src -I../../src/CoreAudioSDK -fasm-blocks -mpascal-strings -Os -gdwarf-2 -arch x86_64 -std=c++14) . <root>/out/Default))

However, I'm getting some errors from flycheck that indicate it doesn't understand the -std=c++14 option:

    6  10 error           'type_traits' file not found... (irony)
   10  33 error           no type named 'function' in namespace 'std'... (irony)
   16  10 error           no type named 'unique_ptr' in namespace 'std'... (irony)

The corresponding .cpp file seems totally fine.

One thing that does work is copying the compile_commands.json into <root>, clearing my cdb-json-projects, and then modifying the compile_commands.json file by hand to have a working directory corresponding to <root>.

russellmcc commented 9 years ago

Oops, actually all of irony is wrong in this situation. I'm moving this to an irony issue.