-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Type: LanguageService
Describe the bug
- OS and Version: Arch Linux (Linux 4.17.9-1-ARCH Code completion with C/C++ extension #1 SMP PREEMPT Sun Jul 22 20:23:36 UTC 2018 x86_64 GNU/Linux)
- VS Code Version: 1.25.1
- C/C++ Extension Version: 0.17.7
- Other extensions you installed (and if the issue persists after disabling them): n/a
The project uses CMake and generates compile_commands.json, which is correctly set in c_cpp_properties.json as "compileCommands": "${workspaceFolder}/output/compile_commands.json". This file is parsed properly, as I see expected info in the "output" tab when I enable high logging level. So for example there is a file external/distortos/source/threads/ThisThread.cpp. When I open it the output log says:
sending compilation args for /home/freddie/Elektronika/ARM/Projects/CWC-STM32F4-mono-graphic-keypad/external/distortos/source/threads/ThisThread.cpp
include: /home/freddie/Elektronika/ARM/Projects/CWC-STM32F4-mono-graphic-keypad/output/external/distortos/include
include: /home/freddie/Elektronika/ARM/Projects/CWC-STM32F4-mono-graphic-keypad/external/distortos/include
include: /home/freddie/Elektronika/ARM/Projects/CWC-STM32F4-mono-graphic-keypad/external/distortos/source/architecture/ARM/ARMv6-M-ARMv7-M/include
include: /home/freddie/Elektronika/ARM/Projects/CWC-STM32F4-mono-graphic-keypad/external/distortos/source/architecture/ARM/ARMv6-M-ARMv7-M/external/CMSIS
include: /home/freddie/Elektronika/ARM/Projects/CWC-STM32F4-mono-graphic-keypad/external/distortos/source/chip/STM32/include
include: /home/freddie/Elektronika/ARM/Projects/CWC-STM32F4-mono-graphic-keypad/external/distortos/source/chip/STM32/STM32F4/include
include: /home/freddie/Elektronika/ARM/Projects/CWC-STM32F4-mono-graphic-keypad/external/distortos/source/chip/STM32/peripherals/GPIOv2/include
include: /home/freddie/Elektronika/ARM/Projects/CWC-STM32F4-mono-graphic-keypad/external/distortos/source/chip/STM32/peripherals/SPIv1/include
include: /home/freddie/Elektronika/ARM/Projects/CWC-STM32F4-mono-graphic-keypad/external/distortos/source/chip/STM32/peripherals/USARTv1/include
include: /home/freddie/Elektronika/ARM/Projects/CWC-STM32F4-mono-graphic-keypad/external/distortos/source/chip/STM32/STM32F4/external/CMSIS-STM32F4
include: /home/freddie/Elektronika/ARM/Projects/CWC-STM32F4-mono-graphic-keypad/external/distortos/source/board/ST_NUCLEO-F429ZI/include
include: /home/freddie/Elektronika/ARM/Projects/CWC-STM32F4-mono-graphic-keypad/external/distortos/source/FileSystem/littlefs/external/littlefs
include: /home/freddie/arm-none-eabi-gcc-7.3.0-180127/arm-none-eabi/include/c++/7.3.0
include: /home/freddie/arm-none-eabi-gcc-7.3.0-180127/arm-none-eabi/include/c++/7.3.0/arm-none-eabi/thumb/v7e-m/fpv4-sp/hard
include: /home/freddie/arm-none-eabi-gcc-7.3.0-180127/arm-none-eabi/include/c++/7.3.0/backward
include: /home/freddie/arm-none-eabi-gcc-7.3.0-180127/lib/gcc/arm-none-eabi/7.3.0/include
include: /home/freddie/arm-none-eabi-gcc-7.3.0-180127/lib/gcc/arm-none-eabi/7.3.0/include-fixed
include: /home/freddie/arm-none-eabi-gcc-7.3.0-180127/arm-none-eabi/include
define: __STDC__=1
...
This is exactly what is used by the compiler, so everything seems fine. Note that the main folder of the project (${workspaceFolder}, which would be /home/freddie/Elektronika/ARM/Projects/CWC-STM32F4-mono-graphic-keypad) is NOT in the include path when compiling this source file. When I would like to add a #include in this file, say /home/freddie/Elektronika/ARM/Projects/CWC-STM32F4-mono-graphic-keypad/external/distortos/include/distortos/ThisThread.hpp, which is available via /home/freddie/Elektronika/ARM/Projects/CWC-STM32F4-mono-graphic-keypad/external/distortos/include, I start typing the path I would like to use, which is #include "distortos/ThisThread.hpp". The problem here is that vscode suggest only #include "external/distortos/include/distortos/ThisThread.hpp" (as if ${workspaceFolder} could be used). This is not the case, file with such include fails to compile:
/home/freddie/arm-none-eabi-gcc-8.2.0-180726/bin/arm-none-eabi-g++ -DLFS_NO_DEBUG -DLFS_NO_ERROR -DLFS_NO_WARN -Iexternal/distortos/include -I../external/distortos/include -I../external/distortos/source/architecture/ARM/ARMv6-M-ARMv7-M/include -I../external/distortos/source/architecture/ARM/ARMv6-M-ARMv7-M/external/CMSIS -I../external/distortos/source/chip/STM32/include -I../external/distortos/source/chip/STM32/STM32F4/include -I../external/distortos/source/chip/STM32/peripherals/GPIOv2/include -I../external/distortos/source/chip/STM32/peripherals/SPIv1/include -I../external/distortos/source/chip/STM32/peripherals/USARTv1/include -I../external/distortos/source/chip/STM32/STM32F4/external/CMSIS-STM32F4 -I../external/distortos/source/board/ST_NUCLEO-F429ZI/include -I../external/distortos/source/FileSystem/littlefs/external/littlefs -fno-use-cxa-atexit -fno-rtti -fno-exceptions -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -g -ggdb3 -O2 -ffunction-sections -fdata-sections -Wall -Wextra -Wshadow -std=gnu++11 -MD -MT external/distortos/CMakeFiles/distortos.dir/source/threads/ThisThread.cpp.o -MF external/distortos/CMakeFiles/distortos.dir/source/threads/ThisThread.cpp.o.d -o external/distortos/CMakeFiles/distortos.dir/source/threads/ThisThread.cpp.o -c ../external/distortos/source/threads/ThisThread.cpp
../external/distortos/source/threads/ThisThread.cpp:12:10: fatal error: external/distortos/include/distortos/ThisThread.hpp: No such file or directory
#include "external/distortos/include/distortos/ThisThread.hpp"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My c_cpp_properties.json:
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}"
],
"defines": [],
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"${workspaceFolder}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"compilerPath": "/home/freddie/arm-none-eabi-gcc-7.3.0-180127/bin/arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16",
"cStandard": "c99",
"cppStandard": "c++11",
"compileCommands": "${workspaceFolder}/output/compile_commands.json"
}
],
"version": 4
}
Expected behavior
In case a header file is available from multiple locations in the include path, I would expect the suggestion which is the shortest and/or the one which has identical beginning to what I type to be prioritized and displayed at the very beginning of the list. So if header.h is located in external/someLibrary/includes/someLibrary via include path set to external/someLibrary/includes then when I type #include "someLibrary/hea..." I would expect to see someLibrary/header.h as the first suggestion, instead of external/someLibrary/includes/someLibrary/header.h as it is now.
Screenshots
after accepting:

