SublimeLinter with C++11

偶尔善良 提交于 2019-12-08 03:27:56

问题


I've started using Sublime Text 3 as my code editor for C++ and I installed some additional packages, two of which being SublimeLinter and SublimeLinter-contrib-clang. Everything seems to be working fine, except that it looks like there is no support for C++11 in the linter.

Do you know how I could change that to work with C++11?


回答1:


According to the SublimeLinter-contrib-clang troubleshooting guide, it can sometimes has issues finding the C++ standard library headers (see bullet 3). If that doesn't work or if you are not stuck using SublimeLinter-contrib-clang, consider using SublimeLinter-cpplint or SublimeLinter-cppcheck instead, as these are meant for C++11 development.




回答2:


For anybody with the same problem:

The solution is to go to Preferences -> Package Settings -> SulbimeLinter -> Settings Default.

There you need to paste the following:

    "linters":
    {
        "clang": {
            "extra_flags": "-std=c++11"
        }
    },

somewhere in the "default" namespace. At least that worked for me.

Cheers!




回答3:


Just in case someone is trying it for Sublime Version 3 and other answers are not helping; following worked for me.

It is also mentioned on the home site: https://github.com/SublimeLinter/SublimeLinter-clang

{
    "linters":
    { 
      "clang++": {
            "args": "-Wall -fsyntax-only -fno-caret-diagnostics -std=c++11",
       },
       "clang": {
            "args": "-Wall -fsyntax-only -fno-caret-diagnostics -std=c++11",
        }
    }
}


来源:https://stackoverflow.com/questions/42330415/sublimelinter-with-c11

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!