You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Request: Allow merge of forcedInclude setting from base config when using compile_commands.json #8274
Hi Łukasz Kurowski (@crackcomm) . It's currently 'by design' that use of compile_commands.json superceeds the other settings in your c_cpp_properties.json. A compile_commands.json should include all compiler args necessary to compile the file. The C/C++ extension uses that entire command line (from either the command field, or the arguments field) to configure IntelliSense to match how the file is actually built. If a forced include is required to compile the file, it should be passed on the command line in compile_commands.json. I don't believe "true" would be a valid compiler command line. The specification for compile_commands.json is here: https://clang.llvm.org/docs/JSONCompilationDatabase.html
Hi Colen Garoutte-Carson (@Colengms), indeed "true" is not a valid compiler command nevertheless it does break the behavior I was expecting. It is a valid command though.
Colen Garoutte-Carson (@Colengms) this request is in the context of #1231 trying to suppress some warnings. Does the new "merge configurations" setting apply for compile_commands.json + forcedInclude?
Bob Brown (@bobbrow) The new merge feature only applies to configuration providers.
Łukasz Kurowski (@crackcomm) When a header file is opened, the extension tries to associate that header with a source file that includes it, and looks for that source file in your compile_commands.json. Note that the purpose of using compile_commands.json with the C/C++ extension is specifically so that configuration information can be inferred based on the compiler args. Without those args present, I don't believe it's accomplishing anything. You might get the behavior you expect by removing use of the compile_commands.json from your cpp_properties.json (or, adding real compile command lines, which use your forced include, to compile_commands.json).
Hi Łukasz Kurowski (@crackcomm) What you are seeing is currently by design. To add a forced include when using compile_commands.json, you would need to specify -include <file> to the command line.
It sounds like you're requesting a feature, that we merge forcedInclude settings from c_cpp_properties.json when using compile_commands.json. So, I'll change this to a feature request.
Reacted by Łukasz Kurowski and TANG ZhiXiong (@dvorak4tzx)
changed the title [-]Can't use forcedInclude with compileCommands[/-][+]Request: Allow merge of `forcedInclude` setting from base config when using `compile_commands.json`[/+]on Oct 14, 2021
Tom G Varik (@tgvarik) FYI, we may move our compile_commands.json handling to the open source TypeScript, so this would be more likely to be implemented after that is done (or we could accept and external PR to for it).
Colen Garoutte-Carson (@Colengms) I encountered a real problem that demonstrates this feature is needed, unless you can advise a workaround.
I'm working on an embedded project using the Altera Nios II processor, the compiler nios2-elf-gcc provides built in functions for memory access. these functions are not visible in any compiler header.
Currently when opening any source file which uses these built in functions, I see in the PROBLEMS tab the following: identifier "____builtin_ldbio" is undefined.
A possible solution is to create a file nios2_stub.h with the following content:
#ifdef__INTELLISENSE__int__builtin_ldbio(volatileconstvoid*);
int__builtin_ldbuio(volatileconstvoid*);
int__builtin_ldhio(volatileconstvoid*);
// more function prototypes followed...#endif
but I will need to explicitly #include this header in my code or add it as a forced include in my CMake build, both options feel like a wrong move as this header exists only for IntelliSense purposes. a better solution IMO would be to add it to the extension's forcedIncludes paths.
for clarity, I am using the compileCommands feature in my project.
Activity
Colengms commentedon Oct 13, 2021
Hi Łukasz Kurowski (@crackcomm) . It's currently 'by design' that use of
compile_commands.jsonsuperceeds the other settings in yourc_cpp_properties.json. Acompile_commands.jsonshould include all compiler args necessary to compile the file. The C/C++ extension uses that entire command line (from either thecommandfield, or theargumentsfield) to configure IntelliSense to match how the file is actually built. If a forced include is required to compile the file, it should be passed on the command line incompile_commands.json. I don't believe "true" would be a valid compiler command line. The specification forcompile_commands.jsonis here: https://clang.llvm.org/docs/JSONCompilationDatabase.htmlcrackcomm commentedon Oct 13, 2021
Hi Colen Garoutte-Carson (@Colengms), indeed "true" is not a valid compiler command nevertheless it does break the behavior I was expecting. It is a valid command though.
crackcomm commentedon Oct 13, 2021
Colen Garoutte-Carson (@Colengms) on the other hand - header files are never included in
compile_commands.json.bobbrow commentedon Oct 13, 2021
Colen Garoutte-Carson (@Colengms) this request is in the context of #1231 trying to suppress some warnings. Does the new "merge configurations" setting apply for compile_commands.json + forcedInclude?
Colengms commentedon Oct 14, 2021
Bob Brown (@bobbrow) The new merge feature only applies to configuration providers.
Łukasz Kurowski (@crackcomm) When a header file is opened, the extension tries to associate that header with a source file that includes it, and looks for that source file in your
compile_commands.json. Note that the purpose of usingcompile_commands.jsonwith the C/C++ extension is specifically so that configuration information can be inferred based on the compiler args. Without those args present, I don't believe it's accomplishing anything. You might get the behavior you expect by removing use of thecompile_commands.jsonfrom yourcpp_properties.json(or, adding real compile command lines, which use your forced include, tocompile_commands.json).crackcomm commentedon Oct 14, 2021
Colen Garoutte-Carson (@Colengms) previously my
compile_commands.jsonwas generated by CMake, the one provided here is enough to reproduce the issue.Colengms commentedon Oct 14, 2021
Hi Łukasz Kurowski (@crackcomm) What you are seeing is currently by design. To add a forced include when using
compile_commands.json, you would need to specify-include <file>to the command line.It sounds like you're requesting a feature, that we merge forcedInclude settings from
c_cpp_properties.jsonwhen usingcompile_commands.json. So, I'll change this to a feature request.[-]Can't use forcedInclude with compileCommands[/-][+]Request: Allow merge of `forcedInclude` setting from base config when using `compile_commands.json`[/+]github-actions commentedon Dec 13, 2021
This feature request is being closed due to insufficient upvotes. When enough upvotes are received, this issue will be eligible for our backlog.
github-actions commentedon Jun 30, 2022
This feature request has received enough votes to be added to our backlog.
tgvarik commentedon Jun 7, 2023
forcedIncludecan't serve as a workaround for #4503 without this.sean-mcmanus commentedon Jun 16, 2023
Tom G Varik (@tgvarik) FYI, we may move our compile_commands.json handling to the open source TypeScript, so this would be more likely to be implemented after that is done (or we could accept and external PR to for it).
yiftahw commentedon Nov 11, 2024
Colen Garoutte-Carson (@Colengms) I encountered a real problem that demonstrates this feature is needed, unless you can advise a workaround.
I'm working on an embedded project using the Altera Nios II processor, the compiler
nios2-elf-gccprovides built in functions for memory access. these functions are not visible in any compiler header.Currently when opening any source file which uses these built in functions, I see in the
PROBLEMStab the following:identifier "____builtin_ldbio" is undefined.A possible solution is to create a file
nios2_stub.hwith the following content:but I will need to explicitly
#includethis header in my code or add it as a forced include in myCMakebuild, both options feel like a wrong move as this header exists only for IntelliSense purposes. a better solution IMO would be to add it to the extension'sforcedIncludespaths.for clarity, I am using the
compileCommandsfeature in my project.