【问题标题】:Default C++ version SublimeLinter默认 C++ 版本 SublimeLinter
【发布时间】:2019-07-17 14:33:04
【问题描述】:

我在 MacOS Mojave 上使用 SublimeLinter-clangSublime 3 来检查 C++ 代码。我收到来自C++ 更高版本的代码的警告和错误。如何将默认 linting 版本设置为 C++17

例如,我有一行:

auto game = SpinOut{};

并且编辑标记如下:

  • 1 warning: clang++ - 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
  • clang++: error - expected '(' for function-style cast or type construction

我尝试按照question 的答案进行操作,但没有任何改变。下面是我的SublimeLinter.sublime.settings,我仍然收到同样的错误和警告。

【问题讨论】:

  • 正如我在原始问题中提到的,我按照该解决方案中的说明进行操作,但没有任何反应。错误仍然出现。我附上了我的SublimeLinter.sublime.settings 的截图。

标签: c++ sublimetext3


【解决方案1】:

SublimeLinter-clang 现在维护在https://github.com/SublimeLinter/SublimeLinter-clang 而不是https://github.com/nirm03/SublimeLinter-clang

在较新的版本中,2018 年有一个拉取请求,增加了支持,使用户能够对 c linter 和 c++ linter 进行不同的设置。因此,https://stackoverflow.com/a/42818098/17034 中 2017 年的答案目前已过时。

所以看起来您需要将 clang 更改为 clang++。看起来他们在设置中将 extra_flags 更改为 args,因此您需要覆盖默认 args 并添加 -std=c++11。

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

【讨论】:

  • 试过了,不幸的是这似乎不起作用。
  • 看起来他们也将 extra_flags 更改为 args。你也可以试试吗?
猜你喜欢
  • 2011-06-30
  • 1970-01-01
  • 2021-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-04-10
  • 2017-02-20
相关资源
最近更新 更多