Using custom CMake toolchain which is referenced in project-local kit .vscode\cmake-kits.json:
[
{
"name": "arm-gcc from CMake Toolchain",
"toolchainFile": "${workspaceRoot}/cmake/arm-gcc-toolchain.cmake"
}
]
Intellisense is configured via .vscode\settings.json to receive configuration from cmake-tools:
{
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"
}
The cmake toolchain succeeds in locating the compiler and cmake-tools receives the compiler information, after I implemented the cmake cache workaround.
The project build works as expected.
However, Intellisense C++ fails to locate the standard C library include files and marks the #include statements with squiggles.
The arm-gcc toolchain is on a Windows machine on a C:\Program Files (x86)\... path, thus containing a whitespace.
When I move it to C:\arm-gnu-toolchain, eliminating the whitespace in the path, and reconfigure the project, then IntelliSense works and the affected #include files are found.
I assume the compiler path is not passed correctly from cmake-tools to IntelliSense, maybe there are quotes missing somewhere along the way.
Can you enable Debug logging for cpptools which will print out the configurations sent by CMake Tools?
After enabling the logging, please run the "Reload Window" command to reset the extension which will cause the configuration to be resent. If you can send that log and also the log printed when you run the "Log Diagnostics" command, that would be super helpful. Thanks!
Surprise: the compiler path seems to be passed correctly to cpptools, AFAICS.
cpptools even lists the compiler include paths to be indexed ...
Maybe it is not a cmake-tools bug, but a cpptools one?
Custom browse configuration received: {
"browsePath": [
<bunch of source paths>
],
"standard": "c++17",
"compilerPath": "c:/program files (x86)/gnu arm embedded toolchain/9 2020-q2-update/bin/arm-none-eabi-g++.exe",
"compilerArgs": []
}
cpptools/didChangeCppProperties
Attempting to get defaults from compiler found on the machine: ''
No suitable compiler found. Please set the "compilerPath" in c_cpp_properties.json.
Code browsing service initialized
Attempting to get defaults from compiler found on the machine: ''
No suitable compiler found. Please set the "compilerPath" in c_cpp_properties.json.
Folder: C:/SRC/UNIFIEDMMC/TRUNK/ will be indexed
cpptools/didChangeCustomBrowseConfiguration
Attempting to get defaults from compiler in "compilerPath" property: 'c:/program files (x86)/gnu arm embedded toolchain/9 2020-q2-update/bin/arm-none-eabi-g++.exe'
Compiler probe command line: c:/program files (x86)/gnu arm embedded toolchain/9 2020-q2-update/bin/arm-none-eabi-g++.exe -std=c++17 -Wp,-v -E -dD -x c++ -m64 nul
Compiler does not support 64-bit. Falling back to 32-bit intelliSenseMode.
Compiler probe command line: c:/program files (x86)/gnu arm embedded toolchain/9 2020-q2-update/bin/arm-none-eabi-g++.exe -std=c++17 -Wp,-v -E -dD -x c++ -m32 nul
Failed to query compiler. Falling back to no bitness.
Compiler probe command line: c:/program files (x86)/gnu arm embedded toolchain/9 2020-q2-update/bin/arm-none-eabi-g++.exe -std=c++17 -Wp,-v -E -dD -x c++ nul
Folder: C:/PROGRAM FILES (X86)/GNU ARM EMBEDDED TOOLCHAIN/9 2020-Q2-UPDATE/LIB/GCC/ARM-NONE-EABI/9.3.1/INCLUDE/ will be indexed
Folder: C:/PROGRAM FILES (X86)/GNU ARM EMBEDDED TOOLCHAIN/9 2020-Q2-UPDATE/LIB/GCC/ARM-NONE-EABI/9.3.1/INCLUDE-FIXED/ will be indexed
Folder: C:/PROGRAM FILES (X86)/GNU ARM EMBEDDED TOOLCHAIN/9 2020-Q2-UPDATE/ARM-NONE-EABI/INCLUDE/ will be indexed
Folder: C:/SRC/UNIFIEDMMC/TRUNK/SRC/ will be indexed
Folder: C:/SRC/UNIFIEDMMC/TRUNK/BUILD/CMAKEFILES/ will be indexed
cpptools/clearCustomConfigurations
cpptools/fileDeleted: file:///c%3A/src/UnifiedMMC/trunk/build/.cmake/api/v1/reply/cache-v2-01a260cfd8f60cdde3ac.json
Populate include completion cache.
Discovering files...
cpptools/fileCreated: file:///c%3A/src/UnifiedMMC/trunk/build/.cmake/api/v1/reply/cache-v2-4930667c738ff51b5427.json
cpptools/fileCreated: file:///c%3A/src/UnifiedMMC/trunk/build/.cmake/api/v1/reply/index-2020-08-20T07-26-12-0073.json
cpptools/fileDeleted: file:///c%3A/src/UnifiedMMC/trunk/build/.cmake/api/v1/reply/index-2020-08-20T07-25-27-0358.json
Processing folder (recursive): C:/PROGRAM FILES (X86)/GNU ARM EMBEDDED TOOLCHAIN/9 2020-Q2-UPDATE/LIB/GCC/ARM-NONE-EABI/9.3.1/INCLUDE/
Processing folder (recursive): C:/PROGRAM FILES (X86)/GNU ARM EMBEDDED TOOLCHAIN/9 2020-Q2-UPDATE/LIB/GCC/ARM-NONE-EABI/9.3.1/INCLUDE-FIXED/
Processing folder (recursive): C:/PROGRAM FILES (X86)/GNU ARM EMBEDDED TOOLCHAIN/9 2020-Q2-UPDATE/ARM-NONE-EABI/INCLUDE/
Processing folder (recursive): C:/SRC/UNIFIEDMMC/TRUNK/SRC/
Custom configuration provider 'CMake Tools' registered
Custom browse configuration received: {
"browsePath": [
<bunch of source paths>
],
"standard": "c++17",
"compilerPath": "c:/program files (x86)/gnu arm embedded toolchain/9 2020-q2-update/bin/arm-none-eabi-g++.exe",
"compilerArgs": []
}
cpptools/pauseParsing
cpptools/clearCustomConfigurations
cpptools/didChangeCustomBrowseConfiguration
cpptools/resumeParsing
Processing folder (recursive): C:/SRC/UNIFIEDMMC/TRUNK/BUILD/CMAKEFILES/
Discovering files: 2081 file(s) processed
11 file(s) removed from database
Done discovering files.
Parsing remaining files...
Parsing: 0 files(s) processed
Done parsing remaining files.
cpptools/clearCustomConfigurations
cpptools/clearCustomConfigurations
Database safe to open
I see "browsePath" configurations sent here, but I didn't see any information about source files that were open for IntelliSense. Can you open one of your source files and share what the "custom" configuration for that file is reported to be? And also run the "Log Diagnostics" command after opening that source file in the editor. This will help us know where things might have gone wrong.
Ok, after opening a source file, cpptools shows in the log the compiler path split by spaces, see bottom of the log.
````
Custom browse configuration received: {
"browsePath": [
("c:/src/unifiedmmc/.......", ...)
],
"standard": "c++17",
"compilerPath": "c:/program files (x86)/gnu arm embedded toolchain/9 2020-q2-update/bin/arm-none-eabi-g++.exe",
"compilerArgs": []
}
cpptools/didChangeCppProperties
Attempting to get defaults from compiler found on the machine: ''
No suitable compiler found. Please set the "compilerPath" in c_cpp_properties.json.
Code browsing service initialized
Attempting to get defaults from compiler found on the machine: ''
No suitable compiler found. Please set the "compilerPath" in c_cpp_properties.json.
Folder: C:/SRC/UNIFIEDMMC/TRUNK/ will be indexed
cpptools/didChangeCustomBrowseConfiguration
Attempting to get defaults from compiler in "compilerPath" property: 'c:/program files (x86)/gnu arm embedded toolchain/9 2020-q2-update/bin/arm-none-eabi-g++.exe'
Compiler probe command line: c:/program files (x86)/gnu arm embedded toolchain/9 2020-q2-update/bin/arm-none-eabi-g++.exe -std=c++17 -Wp,-v -E -dD -x c++ -m64 nul
Compiler does not support 64-bit. Falling back to 32-bit intelliSenseMode.
Compiler probe command line: c:/program files (x86)/gnu arm embedded toolchain/9 2020-q2-update/bin/arm-none-eabi-g++.exe -std=c++17 -Wp,-v -E -dD -x c++ -m32 nul
Failed to query compiler. Falling back to no bitness.
Compiler probe command line: c:/program files (x86)/gnu arm embedded toolchain/9 2020-q2-update/bin/arm-none-eabi-g++.exe -std=c++17 -Wp,-v -E -dD -x c++ nul
Custom configuration provider 'CMake Tools' registered
Custom browse configuration received: {
"browsePath": [
("c:/src/unifiedmmc/.......", ...)
],
"standard": "c++17",
"compilerPath": "c:/program files (x86)/gnu arm embedded toolchain/9 2020-q2-update/bin/arm-none-eabi-g++.exe",
"compilerArgs": []
}
Folder: C:/PROGRAM FILES (X86)/GNU ARM EMBEDDED TOOLCHAIN/9 2020-Q2-UPDATE/LIB/GCC/ARM-NONE-EABI/9.3.1/INCLUDE/ will be indexed
Folder: C:/PROGRAM FILES (X86)/GNU ARM EMBEDDED TOOLCHAIN/9 2020-Q2-UPDATE/LIB/GCC/ARM-NONE-EABI/9.3.1/INCLUDE-FIXED/ will be indexed
Folder: C:/PROGRAM FILES (X86)/GNU ARM EMBEDDED TOOLCHAIN/9 2020-Q2-UPDATE/ARM-NONE-EABI/INCLUDE/ will be indexed
Folder: C:/SRC/UNIFIEDMMC/TRUNK/SRC/ will be indexed
Folder: C:/SRC/UNIFIEDMMC/TRUNK/BUILD/CMAKEFILES/ will be indexed
textDocument/didOpen: file:///c%3A/src/UnifiedMMC/trunk/src/main.c
cpptools/activeDocumentChange: file:///c%3A/src/UnifiedMMC/trunk/src/main.c
cpptools/textEditorSelectionChange
cpptools/clearCustomConfigurations
Checking for syntax errors: file:///c%3A/src/UnifiedMMC/trunk/src/main.c
Populate include completion cache.
Discovering files...
cpptools/getDocumentSymbols: file:///c%3A/src/UnifiedMMC/trunk/src/main.c (id: 2)
cpptools/getDocumentSymbols
cpptools/getCodeActions: file:///c%3A/src/UnifiedMMC/trunk/src/main.c (id: 3)
textDocument/hover: file:///c%3A/src/UnifiedMMC/trunk/src/main.c (id: 4)
IntelliSense client not available, using Tag Parser for go to definition.
IntelliSense client not available, using Tag Parser for quick info.
using Tag Parser for quick info
cpptools/getFoldingRanges: file:///c%3A/src/UnifiedMMC/trunk/src/main.c (id: 5)
cpptools/getSemanticTokens: file:///c%3A/src/UnifiedMMC/trunk/src/main.c (id: 6)
cpptools/pauseParsing
cpptools/clearCustomConfigurations
cpptools/queryTranslationUnitSource: file:///c%3A/src/UnifiedMMC/trunk/src/main.c (id: 7)
Custom configurations received:
uri: file:///c%3A/src/UnifiedMMC/trunk/src/main.c
config: {
"defines": [
"ARM_MATH_CM4=true",
"BOARD=USER_BOARD",
"__ATSAM4LS8C__",
"__SAM4LS8C__",
"printf=iprintf",
"scanf=iscanf",
"DEBUG",
"DEBUG"
],
"standard": "gnu99",
"includePath": [
("c:/src/unifiedmmc/.......", ...)
(no compiler paths here - only project paths)
],
"intelliSenseMode": "gcc-arm",
"compilerPath": "c:/program files (x86)/gnu arm embedded toolchain/9 2020-q2-update/bin/arm-none-eabi-gcc.exe",
"compilerArgs": [
"-g3",
"-Og",
"-Wall",
"-pedantic",
"-DDEBUG",
"-mthumb",
"-mcpu=cortex-m4",
"-mlong-calls",
"-fno-strict-aliasing",
"-ffunction-sections",
"-fdata-sections",
"--param",
"max-inline-insns-single=500",
"-Wall",
"-Wstrict-prototypes",
"-Wmissing-prototypes",
"-Werror-implicit-function-declaration",
"-Wpointer-arith",
"-Wchar-subscripts",
"-Wcomment",
"-Wformat=2",
"-Wimplicit-int",
"-Wmain",
"-Wparentheses",
"-Wsequence-point",
"-Wreturn-type",
"-Wswitch",
"-Wtrigraphs",
"-Wunused",
"-Wuninitialized",
"-Wunknown-pragmas",
"-Wfloat-equal",
"-Wundef",
"-Wshadow",
"-Wbad-function-cast",
"-Wwrite-strings",
"-Wsign-compare",
"-Waggregate-return",
"-Wmissing-declarations",
"-Wformat",
"-Wmissing-format-attribute",
"-Wno-deprecated-declarations",
"-Wpacked",
"-Wredundant-decls",
"-Wnested-externs",
"-Wlong-long",
"-Wunreachable-code",
"-Wcast-align",
"-Wno-expansion-to-defined",
"-Wno-deprecated",
"-Wno-pedantic",
"-DDEBUG",
"-O1",
"-g3",
"-std=gnu99",
"--sysroot=C:/Program Files (x86)/GNU Arm Embedded Toolchain/9 2020-q2-update/bin/../arm-none-eabi"
]
}
cpptools/didChangeCustomBrowseConfiguration
cpptools/didChangeCustomConfiguration
Attempting to get defaults from compiler in "compilerPath" property: 'c:/program files (x86)/gnu arm embedded toolchain/9 2020-q2-update/bin/arm-none-eabi-gcc.exe'
Processing folder (recursive): C:/PROGRAM FILES (X86)/GNU ARM EMBEDDED TOOLCHAIN/9 2020-Q2-UPDATE/LIB/GCC/ARM-NONE-EABI/9.3.1/INCLUDE/
Processing folder (recursive): C:/PROGRAM FILES (X86)/GNU ARM EMBEDDED TOOLCHAIN/9 2020-Q2-UPDATE/LIB/GCC/ARM-NONE-EABI/9.3.1/INCLUDE-FIXED/
Processing folder (recursive): C:/PROGRAM FILES (X86)/GNU ARM EMBEDDED TOOLCHAIN/9 2020-Q2-UPDATE/ARM-NONE-EABI/INCLUDE/
sending compilation args for C:\SRC\UNIFIEDMMC\TRUNK\SRC\MAIN.C
include: C:\PROGRAM FILES (X86)\GNU ARM EMBEDDED TOOLCHAIN\9 2020-Q2-UPDATE\ARM-NONE-EABI\INCLUDE\C++\9.3.1
include: C:\PROGRAM FILES (X86)\GNU ARM EMBEDDED TOOLCHAIN\9 2020-Q2-UPDATE\ARM-NONE-EABI\INCLUDE\C++\9.3.1\ARM-NONE-EABI
include: C:\PROGRAM FILES (X86)\GNU ARM EMBEDDED TOOLCHAIN\9 2020-Q2-UPDATE\ARM-NONE-EABI\INCLUDE\C++\9.3.1\BACKWARD
include: C:\PROGRAM FILES (X86)\GNU ARM EMBEDDED TOOLCHAIN\9 2020-Q2-UPDATE\LIB\GCC\ARM-NONE-EABI\9.3.1\INCLUDE
include: C:\PROGRAM FILES (X86)\GNU ARM EMBEDDED TOOLCHAIN\9 2020-Q2-UPDATE\LIB\GCC\ARM-NONE-EABI\9.3.1\INCLUDE-FIXED
include: C:\PROGRAM FILES (X86)\GNU ARM EMBEDDED TOOLCHAIN\9 2020-Q2-UPDATE\ARM-NONE-EABI\INCLUDE
define: __STDC__=1
(...incredibly long list of defines...)
other: --g++
other: --gnu_version=90301
stdver: c++17
intelliSenseMode: gcc-arm
Shutting down IntelliSense server: C:\SRC\UNIFIEDMMC\TRUNK\SRC\MAIN.C
Processing folder (recursive): C:/SRC/UNIFIEDMMC/TRUNK/SRC/
Processing folder (recursive): C:/SRC/UNIFIEDMMC/TRUNK/BUILD/CMAKEFILES/
Discovering files: 2082 file(s) processed
0 file(s) removed from database
Done discovering files.
Parsing remaining files...
Parsing: 0 files(s) processed
Done parsing remaining files.
Closing the communication channel.
Compiler probe command line: c:/program files (x86)/gnu arm embedded toolchain/9 2020-q2-update/bin/arm-none-eabi-gcc.exe -g3 -Og -Wall -pedantic -mthumb -mcpu=cortex-m4 -mlong-calls -fno-strict-aliasing -ffunction-sections -fdata-sections --param max-inline-insns-single=500 -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int -Wmain -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef -Wshadow -Wbad-function-cast -Wwrite-strings -Wsign-compare -Waggregate-return -Wmissing-declarations -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations -Wpacked -Wredundant-decls -Wnested-externs -Wlong-long -Wunreachable-code -Wcast-align -Wno-expansion-to-defined -Wno-deprecated -Wno-pedantic -O1 -g3 -std=gnu99 --sysroot=C:/Program Files (x86)/GNU Arm Embedded Toolchain/9 2020-q2-update/bin/../arm-none-eabi -Wp,-v -E -dD -x c nul
arm-none-eabi-gcc.exe: error: Files: No such file or directory
arm-none-eabi-gcc.exe: error: (x86)/GNU: No such file or directory
arm-none-eabi-gcc.exe: error: Arm: No such file or directory
arm-none-eabi-gcc.exe: error: Embedded: No such file or directory
arm-none-eabi-gcc.exe: error: Toolchain/9: No such file or directory
arm-none-eabi-gcc.exe: error: 2020-q2-update/bin/../arm-none-eabi: No such file or directory
No suitable compiler found. Please set the "compilerPath" in c_cpp_properties.json.
````
Here's the log diagnostics output. As with the previous log, I shorted the list of files as they're proprietary but there's no compiler related paths there, only project-related ones.
-------- Diagnostics - 21.8.2020, 12:26:42
Version: 0.30.0-insiders2
Current Configuration:
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"intelliSenseMode": "msvc-x64",
"compilerArgs": [],
"configurationProvider": "ms-vscode.cmake-tools",
"browse": {
"path": [
"${workspaceFolder}/**"
],
"limitSymbolsToIncludedHeaders": true
}
}
Custom browse configuration:
{
"browsePath": [
("c:/src/unifiedmmc/trunk/...") (lots of files)
],
"standard": "c++17",
"compilerPath": "c:/program files (x86)/gnu arm embedded toolchain/9 2020-q2-update/bin/arm-none-eabi-g++.exe",
"compilerArgs": []
}
Custom configurations:
[ C:\src\UnifiedMMC\trunk\src\main.c ]
{
"defines": [
"ARM_MATH_CM4=true",
"BOARD=USER_BOARD",
"__ATSAM4LS8C__",
"__SAM4LS8C__",
"printf=iprintf",
"scanf=iscanf",
"DEBUG",
"DEBUG"
],
"standard": "gnu99",
"includePath": [
("c:/src/unifiedmmc/trunk/...") (lots of files)
],
"intelliSenseMode": "gcc-arm",
"compilerPath": "c:/program files (x86)/gnu arm embedded toolchain/9 2020-q2-update/bin/arm-none-eabi-gcc.exe",
"compilerArgs": [
"-g3",
"-Og",
"-Wall",
"-pedantic",
"-DDEBUG",
"-mthumb",
"-mcpu=cortex-m4",
"-mlong-calls",
"-fno-strict-aliasing",
"-ffunction-sections",
"-fdata-sections",
"--param",
"max-inline-insns-single=500",
"-Wall",
"-Wstrict-prototypes",
"-Wmissing-prototypes",
"-Werror-implicit-function-declaration",
"-Wpointer-arith",
"-Wchar-subscripts",
"-Wcomment",
"-Wformat=2",
"-Wimplicit-int",
"-Wmain",
"-Wparentheses",
"-Wsequence-point",
"-Wreturn-type",
"-Wswitch",
"-Wtrigraphs",
"-Wunused",
"-Wuninitialized",
"-Wunknown-pragmas",
"-Wfloat-equal",
"-Wundef",
"-Wshadow",
"-Wbad-function-cast",
"-Wwrite-strings",
"-Wsign-compare",
"-Waggregate-return",
"-Wmissing-declarations",
"-Wformat",
"-Wmissing-format-attribute",
"-Wno-deprecated-declarations",
"-Wpacked",
"-Wredundant-decls",
"-Wnested-externs",
"-Wlong-long",
"-Wunreachable-code",
"-Wcast-align",
"-Wno-expansion-to-defined",
"-Wno-deprecated",
"-Wno-pedantic",
"-DDEBUG",
"-O1",
"-g3",
"-std=gnu99",
"--sysroot=C:/Program Files (x86)/GNU Arm Embedded Toolchain/9 2020-q2-update/bin/../arm-none-eabi"
]
}
Translation Unit Mappings:
Translation Unit Configurations:
Memory Usage: 18 MB
Includes:
(C:\SRC\UNIFIEDMMC\TRUNK\....) (lots of files)
Defines:
ARM_MATH_CM4=true
BOARD=USER_BOARD
__ATSAM4LS8C__
__SAM4LS8C__
printf=iprintf
scanf=iscanf
DEBUG
DEBUG
Standard Version: c99
IntelliSense Mode: gcc-arm
Other Flags:
--gcc
--gnu_version=90100
Total Memory Usage: 18 MB
This is perfect! Thanks for the logs. It looks like the problem is with this compiler flag: "--sysroot=C:/Program Files (x86)/GNU Arm Embedded Toolchain/9 2020-q2-update/bin/../arm-none-eabi". When it is passed to the compiler probe it messes things up because the path is not quoted.
We almost have CMake Tools 1.6.0 release out the door. Until then, if you want, you can also verify if this problem has been fixed correctly by installing the vsix built here: https://github.com/microsoft/vscode-cmake-tools/actions/runs/557242002#artifacts.
Most helpful comment
This is perfect! Thanks for the logs. It looks like the problem is with this compiler flag:
"--sysroot=C:/Program Files (x86)/GNU Arm Embedded Toolchain/9 2020-q2-update/bin/../arm-none-eabi". When it is passed to the compiler probe it messes things up because the path is not quoted.