devtbi / vscode-cppinsights

cppinsights extension for vscode
The Unlicense
12 stars 1 forks source link

Why doesn't it support -- extra-arg-before? #13

Closed Clay-Hex closed 1 year ago

Clay-Hex commented 1 year ago

Why doesn't it support -- extra-arg-before?

Because there is no such option, it cannot be completed when a third-party library is involved in compilation

devtbi commented 1 year ago

this argument is new to me... So, do you want an option to use "extra-arg-before" instead of "extra-arg"? Can you post an example (so call to the insights command with all the arguments)? Then I can investigate.

Clay-Hex commented 1 year ago

this argument is new to me... So, do you want an option to use "extra-arg-before" instead of "extra-arg"? Can you post an example (so call to the insights command with all the arguments)? Then I can investigate.

If you do not add the ‘extra-arg-before’ parameter, when there is a third-party library in the code, it seems that it cannot be compiled? For example, I use nlohmann::json header file in my code, so I can only use ‘-Ithird/json/Include ’ in the 'extra-arg-before' parameter to compile normally and cannot be compiled in 'extra-arg'.

devtbi commented 1 year ago

I've played around a bit... and I don't think the extra-arg/before is the issue. Have you tried specifying an absolute path for the include path?

    "vscode-cppinsights.args": [
        "-std=c++17",
        "-IC:\\Users\\ABC\\DEF\\src\\test\\suite\\folder"
    ],

Also, consider creating a compilation database for the file you are inspecting (& use vscode-cppinsights.buildDirectory). Save the hassle of copying compiler arguments.

If this doesn't help, I'm going to need a concrete example of an insights call that does not work, the error message, and one that does work.... i.e.

& insights .\test\suite\test.cpp   --extra-arg -std=c++17 > test.cpp24156B1Kdvcjg60Ly.cp 
c:\Users\Tobias\Source\Repos\vscode-cppinsights\src\test\suite\test.cpp:4:10: fatal error: 'test.h' file not found
#include "test.h"
         ^~~~~~~~
1 error generated.