Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vscode intellsence智能提示问题,已尝试过所有能尝试的方法,还是无法解决 #229

Open
xb1520 opened this issue Oct 18, 2023 · 5 comments
Labels

Comments

@xb1520
Copy link

xb1520 commented Oct 18, 2023

Xmake 版本

v2.8.3

操作系统版本和架构

win11 x64

描述问题

vscode上使用xmake插件时使用c++20format库,智能提示出错,找不到format。
compile_commands.json,c_cpp_properties.json,settings.json均已配置。
xmake.lua里也设置了c++20
编译器:VS2022附带的MSVCubuntu下的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...

@xb1520 xb1520 added the bug label Oct 18, 2023
@waruqi
Copy link
Member

waruqi commented Oct 18, 2023

这部分includes 是在 msvc 的 INCLUDE env 里面的,不在 -I 里面,目前没导出到 compile commands

@xb1520
Copy link
Author

xb1520 commented Oct 19, 2023

感谢大佬的回答,通过修改c_cpp_properties.json里的compilerPath指定为特定的msvc编译器路径后,显示正常了(还有在xmake里定义的宏在智能提示里并没有检测到),但是我希望xmake可以像cmake那样自动处理这些事情,我不知道cmake是怎么做到的,在vscode里他并没有生成c_cpp_properties.json等文件,也可以做到智能提示,祝xmake越来越好。最后问一下有没有可以完美支持xmake的编辑器

@waruqi
Copy link
Member

waruqi commented Oct 20, 2023

还有在xmake里定义的宏在智能提示里并没有检测到

检查下生成的 compile_command.json 里面有没有这个宏

@LukeXeon
Copy link

[](#229 (comment))
这个确定不要写到文档里面去吗?折腾了半天了终于才找到解决办法

@star-hengxing
Copy link
Contributor

这部分includes 是在 msvc 的 INCLUDE env 里面的,不在 -I 里面,目前没导出到 compile commands

这个现在已经实现了,不过只针对了 clangd。。应该给 cpptools 也搞一个

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants