vscode-cpptools
vscode-cpptools copied to clipboard
intelliSenseMode setting is not compatible with compileCommands setting
Environment
- OS and Version: Ubuntu 22.04
- VS Code Version: 1.84.2
- C/C++ Extension Version: 1.18.5
- If using SSH remote, specify OS of remote machine:
Bug Summary and Steps to Reproduce
Bug Summary:
I set the CompileCommands using the compile_commands.json which is generated by arm-none-eabi-gcc/g++ with Cmake and set the intelliSenseMode to gcc-arm, set the compilerPath to /home/dawi/arm_gnu_toolchains/bin/arm-none-eabi-gcc. but when I open a C source file, the OUTPUT windows said that :
[12/2/2023, 6:16:23 PM] For C++ source files, IntelliSenseMode was changed from "linux-gcc-arm" to "linux-gcc-x86" based on compiler args and querying compilerPath: "/usr/bin/gcc" [12/2/2023, 6:16:23 PM] IntelliSenseMode was changed because it didn't match the detected compiler. Consider setting "compilerPath" instead. Set "compilerPath" to "" to disable detection of system includes and defines. [12/2/2023, 6:16:23 PM] For C source files, IntelliSenseMode was changed from "linux-gcc-arm" to "linux-gcc-x86" based on compiler args and querying compilerPath: "/usr/bin/gcc" [12/2/2023, 6:16:23 PM] IntelliSenseMode was changed because it didn't match the detected compiler. Consider setting "compilerPath" instead. Set "compilerPath" to "" to disable detection of system includes and defines.
it seems that the imtellisenseMode and compilerPath do not work compatible with compilecommands settings.
why ?
Configuration and Logs
content of settings.json file in the .vscode folder :
{
"cmake.configureOnOpen": false,
"C_Cpp.default.compileCommands": "${workspaceFolder}/nuttx/build/compile_commands.json",
"C_Cpp.default.intelliSenseMode": "gcc-arm",
"C_Cpp.default.compilerPath": "/home/dawi/arm_gnu_toolchains/bin/arm-none-eabi-gcc",
}
Other Extensions
part of the content of my compile_commands.json is as following:
{ "directory": "/home/dawi/code/nuttxspace/nuttx/build", "command": "/home/dawi/arm_gnu_toolchains/bin/arm-none-eabi-g++ -D__NuttX__ -I/home/dawi/code/nuttxspace/nuttx/arch/arm/src/stm32 -I/home/dawi/code/nuttxspace/nuttx/arch/arm/src/common -I/home/dawi/code/nuttxspace/nuttx/arch/arm/src/armv7-m -I/home/dawi/code/nuttxspace/nuttx/sched -isystem /home/dawi/code/nuttxspace/nuttx/include -isystem /home/dawi/code/nuttxspace/nuttx/build/include -isystem /home/dawi/code/nuttxspace/nuttx/build/include_arch -nostdinc++ -std=c++14 -mtune=cortex-m4 -march=armv7e-m -mfloat-abi=soft -fno-common -Wall -Wshadow -Wundef -nostdlib -mthumb -Wa,-mthumb -Wa,-mimplicit-it=always -Os -fno-strict-aliasing -fomit-frame-pointer -ffunction-sections -fdata-sections -funwind-tables -o CMakeFiles/nuttx.dir/empty.cxx.obj -c /home/dawi/code/nuttxspace/nuttx/build/empty.cxx", "file": "/home/dawi/code/nuttxspace/nuttx/build/empty.cxx", "output": "CMakeFiles/nuttx.dir/empty.cxx.obj" }, { "directory": "/home/dawi/code/nuttxspace/nuttx/build", "command": "/home/dawi/arm_gnu_toolchains/bin/arm-none-eabi-gcc -D__KERNEL__ -D__NuttX__ -I/home/dawi/code/nuttxspace/nuttx/arch/arm/src/stm32 -I/home/dawi/code/nuttxspace/nuttx/arch/arm/src/common -I/home/dawi/code/nuttxspace/nuttx/arch/arm/src/armv7-m -I/home/dawi/code/nuttxspace/nuttx/include/cxx -I/home/dawi/code/nuttxspace/nuttx/sched -isystem /home/dawi/code/nuttxspace/nuttx/include -isystem /home/dawi/code/nuttxspace/nuttx/build/include -isystem /home/dawi/code/nuttxspace/nuttx/build/include_arch -Wstrict-prototypes -mtune=cortex-m4 -march=armv7e-m -mfloat-abi=soft -fno-common -Wall -Wshadow -Wundef -nostdlib -mthumb -Wa,-mthumb -Wa,-mimplicit-it=always -Os -fno-strict-aliasing -fomit-frame-pointer -ffunction-sections -fdata-sections -fdiagnostics-color=always -D__ASSEMBLY__ -DNDEBUG -funwind-tables -o arch/CMakeFiles/arch.dir/arm/src/armv7-m/arm_exception.S.obj -c /home/dawi/code/nuttxspace/nuttx/arch/arm/src/armv7-m/arm_exception.S", "file": "/home/dawi/code/nuttxspace/nuttx/arch/arm/src/armv7-m/arm_exception.S", "output": "arch/CMakeFiles/arch.dir/arm/src/armv7-m/arm_exception.S.obj" }, { "directory": "/home/dawi/code/nuttxspace/nuttx/build", "command": "/home/dawi/arm_gnu_toolchains/bin/arm-none-eabi-gcc -D__KERNEL__ -D__NuttX__ -I/home/dawi/code/nuttxspace/nuttx/arch/arm/src/stm32 -I/home/dawi/code/nuttxspace/nuttx/arch/arm/src/common -I/home/dawi/code/nuttxspace/nuttx/arch/arm/src/armv7-m -I/home/dawi/code/nuttxspace/nuttx/include/cxx -I/home/dawi/code/nuttxspace/nuttx/sched -isystem /home/dawi/code/nuttxspace/nuttx/include -isystem /home/dawi/code/nuttxspace/nuttx/build/include -isystem /home/dawi/code/nuttxspace/nuttx/build/include_arch -Wstrict-prototypes -mtune=cortex-m4 -march=armv7e-m -mfloat-abi=soft -fno-common -Wall -Wshadow -Wundef -nostdlib -mthumb -Wa,-mthumb -Wa,-mimplicit-it=always -Os -fno-strict-aliasing -fomit-frame-pointer -ffunction-sections -fdata-sections -fdiagnostics-color=always -D__ASSEMBLY__ -DNDEBUG -funwind-tables -o arch/CMakeFiles/arch.dir/arm/src/armv7-m/arm_saveusercontext.S.obj -c /home/dawi/code/nuttxspace/nuttx/arch/arm/src/armv7-m/arm_saveusercontext.S", "file": "/home/dawi/code/nuttxspace/nuttx/arch/arm/src/armv7-m/arm_saveusercontext.S", "output": "arch/CMakeFiles/arch.dir/arm/src/armv7-m/arm_saveusercontext.S.obj" }, { "directory": "/home/dawi/code/nuttxspace/nuttx/build", "command": "/home/dawi/arm_gnu_toolchains/bin/arm-none-eabi-gcc -D__KERNEL__ -D__NuttX__ -I/home/dawi/code/nuttxspace/nuttx/arch/arm/src/stm32 -I/home/dawi/code/nuttxspace/nuttx/arch/arm/src/common -I/home/dawi/code/nuttxspace/nuttx/arch/arm/src/armv7-m -I/home/dawi/code/nuttxspace/nuttx/include/cxx -I/home/dawi/code/nuttxspace/nuttx/sched -isystem /home/dawi/code/nuttxspace/nuttx/include -isystem /home/dawi/code/nuttxspace/nuttx/build/include -isystem /home/dawi/code/nuttxspace/nuttx/build/include_arch -Wstrict-prototypes -mtune=cortex-m4 -march=armv7e-m -mfloat-abi=soft -fno-common -Wall -Wshadow -Wundef -nostdlib -mthumb -Wa,-mthumb -Wa,-mimplicit-it=always -Os -fno-strict-aliasing -fomit-frame-pointer -ffunction-sections -fdata-sections -fdiagnostics-color=always -Wstrict-prototypes -DNDEBUG -funwind-tables -o arch/CMakeFiles/arch.dir/arm/src/armv7-m/arm_busfault.c.obj -c /home/dawi/code/nuttxspace/nuttx/arch/arm/src/armv7-m/arm_busfault.c", "file": "/home/dawi/code/nuttxspace/nuttx/arch/arm/src/armv7-m/arm_busfault.c", "output": "arch/CMakeFiles/arch.dir/arm/src/armv7-m/arm_busfault.c.obj" }, { "directory": "/home/dawi/code/nuttxspace/nuttx/build", "command": "/home/dawi/arm_gnu_toolchains/bin/arm-none-eabi-gcc -D__KERNEL__ -D__NuttX__ -I/home/dawi/code/nuttxspace/nuttx/arch/arm/src/stm32 -I/home/dawi/code/nuttxspace/nuttx/arch/arm/src/common -I/home/dawi/code/nuttxspace/nuttx/arch/arm/src/armv7-m -I/home/dawi/code/nuttxspace/nuttx/include/cxx -I/home/dawi/code/nuttxspace/nuttx/sched -isystem /home/dawi/code/nuttxspace/nuttx/include -isystem /home/dawi/code/nuttxspace/nuttx/build/include -isystem /home/dawi/code/nuttxspace/nuttx/build/include_arch -Wstrict-prototypes -mtune=cortex-m4 -march=armv7e-m -mfloat-abi=soft -fno-common -Wall -Wshadow -Wundef -nostdlib -mthumb -Wa,-mthumb -Wa,-mimplicit-it=always -Os -fno-strict-aliasing -fomit-frame-pointer -ffunction-sections -fdata-sections -fdiagnostics-color=always -Wstrict-prototypes -DNDEBUG -funwind-tables -o arch/CMakeFiles/arch.dir/arm/src/armv7-m/arm_cache.c.obj -c /home/dawi/code/nuttxspace/nuttx/arch/arm/src/armv7-m/arm_cache.c", "file": "/home/dawi/code/nuttxspace/nuttx/arch/arm/src/armv7-m/arm_cache.c", "output": "arch/CMakeFiles/arch.dir/arm/src/armv7-m/arm_cache.c.obj" },
Additional context
No response
compile_commands.json should be picked up unless you have a compilerPath set in c_cpp_properties.json or if there’s some error in querying the compiler. Could you please provide the log diagnositics via the C/C++: Log Diagnostics command to provide more context?
As a workaround, you should be able to set the compilerPath in c_cpp_properties.json
I believe this may be addressed in 1.19.3. If I understand correctly, there are two issues that may be related:
-
When a
compilerPathis specified, it should override the compiler incompile_commands.json. (This was originally intended as a work-around, but we're considering changing this behavior. This is tracked by https://github.com/microsoft/vscode-cpptools/issues/11889 ). However, there is a bug preventing thatcompilerPathfrom being conbined with the compiler arguments incompile_commands.jsonto properly resolve the configuration. In 1.19.3, this should be fixed such that it combines thecompilerPathwith the args fromcompile_commands.jsonproperly. By specifying the same compiler in bothcompile_commands.jsonand your base configuration, that ensures both configurations fromcompile_commands.jsonwork as expected, and files not found incompile_commands.jsonget configured properly to use thecompilerPathin their base configuration. (Whereas, if thecompilerPathwere not present, it would fall back to some default detected compiler.) -
There was an issue with those
IntelliSenseMode was changed frommessages being reported for compiler queries based oncompile_commands.jsonentries. SinceIntelliSenseModeis specific to the base configuration, there should be no such warning when resolvingcompile_commands.jsonentries. Those incorrect warnings will be removed in 1.19.3.
This should be addressed in 1.19.4. If you're still seeing an issue with >=1.19.4, let us know.