V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
PowerDi
V2EX  ›  Visual Studio Code

Vscode 的 c++插件提示问题

  •  
  •   PowerDi · 13 天前 · 1381 次点击
    代码在 IDE 里提示有错误时,已修复但还是提示修复前的错误提示。需要对项目进行编译后波浪线错误就会消失了,有时在编译前老以为自己写的还是不对。

    印象中只有某台电脑才这样,而且电脑 Linux 都重装过了,还是有这样的问题
    16 条回复    2024-09-04 11:27:14 +08:00
    flax5a98aa2
        1
    flax5a98aa2  
       13 天前
    我这边一直都是这样👀
    proxytoworld
        2
    proxytoworld  
       13 天前
    我也是这样,改完之后还是有波浪线,要编译一下才没了
    Cnming
        3
    Cnming  
       13 天前 via iPhone   ❤️ 1
    用的是默认的 cpptools 么,试试 clangd 呢
    valord577
        4
    valord577  
       13 天前
    长期用 clangd 根据 json 补全 速度比 cpptools 快很多 暂时没遇到你说的问题 建议捣鼓试试
    wkla
        5
    wkla  
       13 天前
    哪怕在 Visual Studio 里都会有这样的问题,这可能是微软的 intelli sence 通病?
    exhades
        6
    exhades  
       13 天前
    用 clangd 并且为项目生成 compile_commands.json 就 ok
    nooneanyone
        7
    nooneanyone  
       13 天前
    用 clangd
    ashong
        8
    ashong  
       13 天前 via iPhone
    clangd 速度快,但是如果配合 cmake 只支持 makefile 和 ninja , 否则无法生成 compile_commands.json ,自己的类无法识别
    PowerDi
        9
    PowerDi  
    OP
       12 天前
    @flax5a98aa2 原来不是只有我是这样!
    PowerDi
        10
    PowerDi  
    OP
       12 天前
    @Cnming 是默认的 cpptools 。
    PowerDi
        11
    PowerDi  
    OP
       12 天前
    @valord577 根据 json 会用到 compile_commands.json 吗? cpp 工具也是可以支持这个的
    PowerDi
        12
    PowerDi  
    OP
       12 天前
    cpptools 我是一直启用了对 compile_commands.json 的支持,路径也配正确了。
    valord577
        13
    valord577  
       12 天前
    @PowerDi #11 对 就是 compile_commands.json 这个

    cmake meson 可以直接生成 compile_commands.json

    makefile autotools 可以搭配 bear 这个工具 bear -- make -j 也能生成 json
    valord577
        14
    valord577  
       12 天前
    @PowerDi #13 补充

    如果是 linux apt 系列的发行版 可以直接添加 llvm-apt 源 apt install clangd-{version} 然后在 vscode 插件配置`clangd.path: /usr/bin/clangd-{version}`

    如果 mac 的话 考虑 brew / windows vs installer 可以安装 llvm 工具链 (独立组件)

    如果是 windows/mac 可以考虑这个脚本 进行静态编译 https://github.com/clangd/clangd/issues/514#issuecomment-2327754089
    PowerDi
        15
    PowerDi  
    OP
       12 天前
    @valord577 #13 我喜欢用 Name: C/C++ Definition Autocompletion 这个插件的补全功能,有时候头文件写了很多 Setter 函数,在 cpp 里直接输入.就能提醒补全命名空间跟形参,跟头文件对应。用 cpptools 时这个插件能用,用 clangd 好像会被自带的.给功能覆盖了,所以用一段时间就不用了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   934 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 19:29 · PVG 03:29 · LAX 12:29 · JFK 15:29
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.