vscode intellsence智能提示问题,已尝试过所有能尝试的方法,还是无法解决
xb1520 opened this issue · 5 comments
Xmake 版本
v2.8.3
操作系统版本和架构
win11 x64
描述问题
vscode上使用xmake插件时使用c++20的format库,智能提示出错,找不到format。
compile_commands.json,c_cpp_properties.json,settings.json均已配置。
xmake.lua里也设置了c++20。
编译器:VS2022附带的MSVC,ubuntu下的gcc-11(链接的fmt)的c++,intellsence均无法找到头文件,但是都可以正常编译
期待的结果
希望vscode xmake intellsence智能提示问题可以解决
工程配置
xmake.lua
尝试过set_languages("c++20")也不行
add_rules("plugin.compile_commands.autoupdate", {outputdir = ".vscode"})
add_rules("mode.debug", "mode.release")
target("x1")
set_kind("binary")
set_languages("cxx20")
add_files("src/*.cpp")
main.cpp
#include <iostream>
#include <format>
using namespace std;
int main(int argc, char** argv)
{
cout << std::format("{}","hello world!") << endl;
return 0;
}
compile_commands.json
[
{
"directory": "D:\\Project\\x1\\x1",
"arguments": ["D:\\Program\\work\\ide\\VS2022\\ide\\VC\\Tools\\MSVC\\14.35.32215\\bin\\HostX64\\x64\\cl.exe", "/c", "/nologo", "/Zi", "/FS", "/Fdbuild\\windows\\x64\\debug\\compile.x1.pdb", "/Od", "/std:c++20", "/EHsc", "/Fobuild\\.objs\\x1\\windows\\x64\\debug\\src\\main.cpp.obj", "src\\main.cpp"],
"file": "src\\main.cpp"
}]
c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"${vcpkgRoot}/x64-windows/include",
"${vcpkgRoot}/x86-windows/include"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:\\Strawberry\\c\\bin\\gcc.exe",
"cStandard": "c11",
"cppStandard": "c++14",
"intelliSenseMode": "windows-gcc-x86",
"compileCommands": "${workspaceFolder}/.vscode/compile_commands.json"
}
],
"version": 4
}
settings.json
{
"files.associations": {
"*.cjson": "jsonc",
"*.wxss": "css",
"*.wxs": "javascript",
"ostream": "cpp",
"*.tcc": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cstdarg": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"exception": "cpp",
"initializer_list": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"new": "cpp",
"streambuf": "cpp",
"type_traits": "cpp",
"typeinfo": "cpp"
},
"configuration": {
"type": "object",
"title": "XMake configuration",
"properties": {
"xmake.executable": {
"type": "string",
"default": "xmake",
"description": "The xmake executable name / path"
},
"xmake.logLevel": {
"type": "string",
"default": "normal",
"description": "The Log Level: normal/verbose/minimal",
"enum": [
"verbose",
"normal",
"minimal"
]
},
"xmake.buildLevel": {
"type": "string",
"default": "normal",
"description": "The Build Output Level: normal/verbose/warning/debug",
"enum": [
"verbose",
"normal",
"warning",
"debug"
]
},
"xmake.buildDirectory": {
"type": "string",
"default": "${workspaceRoot}/build",
"description": "The Build Output Directory"
},
"xmake.installDirectory": {
"type": "string",
"default": "",
"description": "The Install Output Directory"
},
"xmake.packageDirectory": {
"type": "string",
"default": "",
"description": "The Package Output Directory"
},
"xmake.workingDirectory": {
"type": "string",
"default": "${workspaceRoot}",
"description": "The Project Working Directory with the root xmake.lua"
},
"xmake.androidNDKDirectory": {
"type": "string",
"default": "",
"description": "The Android NDK Directory"
}
}
}
}
附加信息和错误日志
emmm...
这部分includes 是在 msvc 的 INCLUDE env 里面的,不在 -I 里面,目前没导出到 compile commands
感谢大佬的回答,通过修改c_cpp_properties.json里的compilerPath指定为特定的msvc编译器路径后,显示正常了(还有在xmake里定义的宏在智能提示里并没有检测到),但是我希望xmake可以像cmake那样自动处理这些事情,我不知道cmake是怎么做到的,在vscode里他并没有生成c_cpp_properties.json等文件,也可以做到智能提示,祝xmake越来越好。最后问一下有没有可以完美支持xmake的编辑器
还有在xmake里定义的宏在智能提示里并没有检测到
检查下生成的 compile_command.json 里面有没有这个宏