vscode-cpptools
vscode-cpptools copied to clipboard
Improve handling of relative paths in `directory` field of `compile_commands.json` (spec is unclear)
Environment
- OS and Version: Windows 10 Enterpise
- VS Code Version: 1.89.00
- C/C++ Extension Version: 1.20.5
- If using SSH remote, specify OS of remote machine:
Bug Summary and Steps to Reproduce
Bug Summary:
cpp files no longer get found in compile_commands.json, regression to 1.19.9
Steps to reproduce:
Activate cpp file, expect intellisense to parse and find include files. Get this error, switching back to 1.19. 9 fixes the issue:
[5/8/2024, 8:05:56 AM] "XBYCSCreatePoolData.cpp" not found in "e:\ws\3dbyme/.vscode/compile_commands.json". 'includePath' from c_cpp_properties.json in folder '3DBYME' will be used for this file instead.
Expected behavior:
File to be found, and intellisense to work
Configuration and Logs
{
"configurations": [
{
"name": "Win32",
"includePath": [],
"defines": [],
"windowsSdkVersion": "10.0.17763.0",
"compilerPath": "C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.34.31933/bin/Hostx86/x64/cl.exe",
"compileCommands": "${workspaceFolder}/.vscode/compile_commands.json",
"cStandard": "c11",
"cppStandard": "c++20",
"intelliSenseMode": "windows-msvc-x64",
"browse": {}
}
],
"version": 4
}
Configuration warnings:
[5/8/2024, 8:15:39 AM] "XBYCSStockOperation.cpp" not found in "e:\ws\3dbyme/.vscode/compile_commands.json". 'includePath' from c_cpp_properties.json in folder '3DBYME' will be used for this file instead.
[5/8/2024, 8:15:44 AM] "XBYCSCreatePoolData.cpp" not found in "e:\ws\3dbyme/.vscode/compile_commands.json". 'includePath' from c_cpp_properties.json in folder '3DBYME' will be used for this file instead.
Entries for for the 2 files listed as missing:
{
"directory": "XBYCSCommands/XBYCSCommandOperations.m/src",
"file": "XBYCSStockOperation.cpp",
"command": "cl /DCNEXT_CLIENT /DNATIVE_EXCEPTION /DOS_Windows_NT /DPLATEFORME_DS64 /DUNICODE /DWIN64 /DWINVER=0x0601 /D_AFXDLL /D_AMD64_=1 /D_CAT_ANSI_STREAMS /D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_DS_PLATEFORME_64 /D_ENDIAN_LITTLE /D_LANGUAGE_CPLUSPLUS /D_MFC_VER=0x0E00 /D_MK_CONTNAME_=XBYCSCommandOperations /D_MK_FWNAME_=XBYCSCommands /D_MK_MODNAME_=XBYCSCommandOperations /D_UNICODE /D_WIN32_WINNT=0x0601 /D_WIN64 /D_WINDOWS /D_WINDOWS_SOURCE /D_WINNT_SOURCE /D__XBYCSCommandOperations /EHs /FIE:\\ws\\prereqs\\r426_debug\\.\\BSFBuildtimeData\\PublicInterfaces\\CATIAV5Precompiled.h /FIE:\\ws\\prereqs\\r426_debug\\.\\BSFBuildtimeData\\PublicInterfaces\\CATWarningPromote.h /GS- /MD /Od /W3 /Zc:__cplusplus /Zc:forScope /Zc:wchar_t /Zi /permissive- /std:c++20 /w14239 /wd4251 /wd4290 /D_MK_FWNAME_=XBYCSCommands /D_MK_MODNAME_=XBYCSCommandOperations /D_MK_CONTNAME_=XBYCSCommandOperations /I./XBYCSCommands/XBYCSCommandOperations.m/src /I./XBYCSCommands/XBYCSCommandOperations.m/LocalInterfaces /I./XBYCSCommands/XBYCSCommandOperations.m/LocalGenerated/win_b64 /I./XBYCSCommands/PrivateInterfaces /I./XBYCSCommands/ProtectedInterfaces /I./XBYCSCommands/ImportedInterfaces/win_b64 /IE:/ws/tools/mkmk/r426/win_b64/tools/include/Windows /IE:/ws/tools/mkmk/r426/win_b64/tools/include XBYCSStockOperation.cpp"
},
{
"directory": "XBYCSCommands/XBYCSCommandOperations.m/src",
"file": "XBYCSCreatePoolData.cpp",
"command": "cl /DCNEXT_CLIENT /DNATIVE_EXCEPTION /DOS_Windows_NT /DPLATEFORME_DS64 /DUNICODE /DWIN64 /DWINVER=0x0601 /D_AFXDLL /D_AMD64_=1 /D_CAT_ANSI_STREAMS /D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_DS_PLATEFORME_64 /D_ENDIAN_LITTLE /D_LANGUAGE_CPLUSPLUS /D_MFC_VER=0x0E00 /D_MK_CONTNAME_=XBYCSCommandOperations /D_MK_FWNAME_=XBYCSCommands /D_MK_MODNAME_=XBYCSCommandOperations /D_UNICODE /D_WIN32_WINNT=0x0601 /D_WIN64 /D_WINDOWS /D_WINDOWS_SOURCE /D_WINNT_SOURCE /D__XBYCSCommandOperations /EHs /FIE:\\ws\\prereqs\\r426_debug\\.\\BSFBuildtimeData\\PublicInterfaces\\CATIAV5Precompiled.h /FIE:\\ws\\prereqs\\r426_debug\\.\\BSFBuildtimeData\\PublicInterfaces\\CATWarningPromote.h /GS- /MD /Od /W3 /Zc:__cplusplus /Zc:forScope /Zc:wchar_t /Zi /permissive- /std:c++20 /w14239 /wd4251 /wd4290 /D_MK_FWNAME_=XBYCSCommands /D_MK_MODNAME_=XBYCSCommandOperations /D_MK_CONTNAME_=XBYCSCommandOperations /I./XBYCSCommands/XBYCSCommandOperations.m/src /I./XBYCSCommands/XBYCSCommandOperations.m/LocalInterfaces /I./XBYCSCommands/XBYCSCommandOperations.m/LocalGenerated/win_b64 /I./XBYCSCommands/PrivateInterfaces /I./XBYCSCommands/ProtectedInterfaces /I./XBYCSCommands/ImportedInterfaces/win_b64 /IE:/ws/tools/mkmk/r426/win_b64/tools/include/Windows /IE:/ws/tools/mkmk/r426/win_b64/tools/include XBYCSCreatePoolData.cpp"
},
Other Extensions
No response
Additional context
No response
So, I think I've found the issue, in 1.19.9 paths are resolved relative to the workspace folder, so this entry in compile_commands.json works:
[
{
"directory": "XBYCSCommands/XBYCSCommandOperations.m/src",
"file": "XBYCSCutSlotOperation.cpp",
"command": "cl /DCNEXT_CLIENT /DNATIVE_EXCEPTION /DOS_Windows_NT /DPLATEFORME_DS64 /DUNICODE /DWIN64 /DWINVER=0x0601 /D_AFXDLL /D_AMD64_=1 /D_CAT_ANSI_STREAMS /D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_DS_PLATEFORME_64 /D_ENDIAN_LITTLE /D_LANGUAGE_CPLUSPLUS /D_MFC_VER=0x0E00 /D_MK_CONTNAME_=XBYCSCommandOperations /D_MK_FWNAME_=XBYCSCommands /D_MK_MODNAME_=XBYCSCommandOperations /D_UNICODE /D_WIN32_WINNT=0x0601 /D_WIN64 /D_WINDOWS /D_WINDOWS_SOURCE /D_WINNT_SOURCE /D__XBYCSCommandOperations /EHs /FIE:\\ws\\prereqs\\r426_debug\\.\\BSFBuildtimeData\\PublicInterfaces\\CATIAV5Precompiled.h /FIE:\\ws\\prereqs\\r426_debug\\.\\BSFBuildtimeData\\PublicInterfaces\\CATWarningPromote.h /GS- /MD /Od /W3 /Zc:__cplusplus /Zc:forScope /Zc:wchar_t /Zi /permissive- /std:c++20 /w14239 /wd4251 /wd4290 /D_MK_FWNAME_=XBYCSCommands /D_MK_MODNAME_=XBYCSCommandOperations /D_MK_CONTNAME_=XBYCSCommandOperations /I./XBYCSCommands/XBYCSCommandOperations.m/src /I./XBYCSCommands/XBYCSCommandOperations.m/LocalInterfaces /I./XBYCSCommands/XBYCSCommandOperations.m/LocalGenerated/win_b64 /I./XBYCSCommands/PrivateInterfaces /I./XBYCSCommands/ProtectedInterfaces /I./XBYCSCommands/ImportedInterfaces/win_b64 /IE:/ws/tools/mkmk/r426/win_b64/tools/include/Windows /IE:/ws/tools/mkmk/r426/win_b64/tools/include XBYCSCutSlotOperation.cpp"
}
]
It fails in 1.20.5, but can be fixed by having the fully resolved paths:
[
{
"directory": "E:/ws/3dbyme/XBYCSCommands/XBYCSCommandOperations.m/src/",
"file": "XBYCSCutSlotOperation.cpp",
"command": "cl /DCNEXT_CLIENT /DNATIVE_EXCEPTION /DOS_Windows_NT /DPLATEFORME_DS64 /DUNICODE /DWIN64 /DWINVER=0x0601 /D_AFXDLL /D_AMD64_=1 /D_CAT_ANSI_STREAMS /D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_DS_PLATEFORME_64 /D_ENDIAN_LITTLE /D_LANGUAGE_CPLUSPLUS /D_MFC_VER=0x0E00 /D_MK_CONTNAME_=XBYCSCommandOperations /D_MK_FWNAME_=XBYCSCommands /D_MK_MODNAME_=XBYCSCommandOperations /D_UNICODE /D_WIN32_WINNT=0x0601 /D_WIN64 /D_WINDOWS /D_WINDOWS_SOURCE /D_WINNT_SOURCE /D__XBYCSCommandOperations /EHs /FIE:/ws/prereqs/r426_debug/./BSFBuildtimeData/PublicInterfaces/CATIAV5Precompiled.h /FIE:/ws/prereqs/r426_debug/./BSFBuildtimeData/PublicInterfaces/CATWarningPromote.h /GS- /MD /Od /W3 /Zc:__cplusplus /Zc:forScope /Zc:wchar_t /Zi /permissive- /std:c++20 /w14239 /wd4251 /wd4290 /D_MK_FWNAME_=XBYCSCommands /D_MK_MODNAME_=XBYCSCommandOperations /D_MK_CONTNAME_=XBYCSCommandOperations /Ie:/ws/3dbyme/XBYCSCommands/XBYCSCommandOperations.m/src /Ie:/ws/3dbyme/XBYCSCommands/XBYCSCommandOperations.m/LocalInterfaces /Ie:/ws/3dbyme/XBYCSCommands/XBYCSCommandOperations.m/LocalGenerated/win_b64 /Ie:/ws/3dbyme/XBYCSCommands/PrivateInterfaces /Ie:/ws/3dbyme/XBYCSCommands/ProtectedInterfaces /Ie:/ws/3dbyme/XBYCSCommands/ImportedInterfaces/win_b64 /IE:/ws/tools/mkmk/r426/win_b64/tools/include/Windows /IE:/ws/tools/mkmk/r426/win_b64/tools/include XBYCSCutSlotOperation.cpp"
}
]
Hi @ddignam . The documentation for compile_commands.json is unclear on whether the directory field must be a full path, or what it's relative to if not a full path. The only examples it provides are full paths.
We can use this issue to ensure the behavior is consistent - either always relative to the workspace folder or relative to its location. (Using its current location would seem to be less ambiguous.) Though, since it's unclear what the correct behavior should be, I'd recommend not using a relative path in that field, as other tools may interpret it differently. I'd suggest also following up with an issue against LLVM asking for documentation to be updated to clarify the validity and behavior of relative paths in the directory field. compile_commands.json specification ambiguities have actually come up in the past, which they've updated the documentation to clarify.
Please make this default to workspace folder again.
@ddignam Fixed with https://github.com/microsoft/vscode-cpptools/releases/tag/v1.21.1