Sarcasm / irony-mode

A C/C++ minor mode for Emacs powered by libclang
GNU General Public License v3.0
901 stars 98 forks source link

Irony breaks when (accidentally) including a `.a` file into compile args #522

Open cody-c opened 5 years ago

cody-c commented 5 years ago

This is a very edge-case issue that I ran into. I'm documenting it here not because it needs to be fixed but rather in case it can help someone else in the future.

Issue: In my makefile I linked directly against a specific version of a static library using it's full path (i.e. /usr/lib/libsome_library.a). When running bear on my makefile it treated that direct file link as an include and generated a compile_commands.json that looked like this:

[
    {
        "arguments": [
            "g++",
            "-c",
            "-std=c++11",
            "-g",
            "-I/usr/include",
            "/usr/lib/libsome_library.a"
            "-o",
            "myProgram",
            "myProgram.cpp"
        ],
        "directory": "/home/cc/myProgram",
        "file": "myProgram.cpp"
    }
]

Which in turn got parsed into an include argument and broke Irony with the following error:

Irony I/O task: error in callback: (irony-server-error complete-error "failed to perform code completion" "path/to/.cpp" line# col#)

The fix is simple, remove the .a file from the list of compile arguments.

Hope this can help someone struggling with the same issue.

smcallis commented 4 years ago

I had the same problem with .o files, so thanks for this tip.

bvandonselaar commented 4 years ago

I had the same problem with .o files, so thanks for this tip.

Yhea that was the parsing error for me, thanks. I used Bear to generate compile_commands.json btw.