proxytoworld

vscode 的 c/C++插件会调整代码 include 的头文件顺序,怎么关闭

  •  
  •   proxytoworld · Jul 9, 2024 · 2271 views
    This topic created in 694 days ago, the information mentioned may be changed or developed.

    如题,假如我 include 了如下顺序的文件

    #include<b.h>
    #include<a.h>
    

    因为 a 比 b 小,所以在保存代码的时候,自动 format ,会变成如下顺序

    #include<a.h>
    #include<b.h>
    

    有的时候因为头文件包含顺序,会导致重复定义等问题,怎么关闭这个功能啊,在设置里面没找到,谷歌也没类似的

    6 replies    2024-07-10 15:39:38 +08:00
    0o0O0o0O0o
        1
    0o0O0o0O0o  
       Jul 9, 2024   ❤️ 1
    proxytoworld
        2
    proxytoworld  
    OP
       Jul 9, 2024
    @0o0O0o0O0o 保留 format ,关闭调整头文件顺序的功能,但我不确定有没有这样的开关
    proxytoworld
        3
    proxytoworld  
    OP
       Jul 9, 2024
    看起来应该可以
    @0o0O0o0O0o
    Maboroshii
        4
    Maboroshii  
       Jul 10, 2024 via Android
    重复定义一般不都是用宏解决嘛
    csl123
        5
    csl123  
       Jul 10, 2024
    setting.json 里设置一下就行了


    "editor.codeActionsOnSave": {
    "source.organizeImports": "never",
    },
    nmap
        6
    nmap  
       Jul 10, 2024
    这个功能确实脑残,格式化工具不应该去改变代码逻辑,有时候 include 顺序改了就不对了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1051 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 22:53 · PVG 06:53 · LAX 15:53 · JFK 18:53
    ♥ Do have faith in what you're doing.