如何设置全局的`flycheck-gcc-language-standard`?

求教如何设置全局的flycheck-gcc-language-standard。目前设置dir local的变量是没有问题的,但是全局的无法生效。

测试过如下的code,然而并不行,也试过make-local-variable,还是不行。

(add-hook 'c++-mode-hook (lambda () (setq flycheck-clang-language-standard "c++11")))

setq-default :

也试过,并不行。

问题是它定义的时候使用了make-variable-buffer-local, 导致只有 buffer local variable才生效。

(flycheck-def-option-var flycheck-clang-language-standard nil c/c++-clang
  "The language standard to use in Clang.

The value of this variable is either a string denoting a language
standard, or nil, to use the default standard.  When non-nil,
pass the language standard via the `-std' option."
  :type '(choice (const :tag "Default standard" nil)
                 (string :tag "Language standard"))
  :safe #'stringp
  :package-version '(flycheck . "0.15"))
(make-variable-buffer-local 'flycheck-clang-language-standard)

好像用dir local也不行,之前测试错误。

.dir-locals.el

((c++-mode
  (flycheck-gcc-language-standard . "c++11")))

解决了,设置globally是没问题的,就是上面那样。

我的问题是clang使用std::function是不需要include 的,然而gcc需要,然后我一直以为是gcc不work,蛋疼。

我也遇到这个问题,全局是可以生效的。 请问下怎么在 .dir-locals.el 下设置?

已解决,这样设置就可以在 .dir-locals.el 生效了:

((c++-mode . ((flycheck-clang-language-standard . "c++20"))))

参考 emacsWiki