I'm new to Emacs. How can I set the Flycheck package to use C standard 99 (C99 mode)? For the following code:
for(int i = 0; i < n; i++)
...
Flycheck will throw me: for loop initial declarations are only allowed in C99 mode
.
Directory VariablesまたはFile Variablesを介して、flycheck-clang-language-standard
またはflycheck-gcc-language-standard
(インストールしたツールに応じて) を に設定します。"gnu99"
前者の場合は、 と入力しM-x add-dir-local-variable RET c-mode RET flycheck-clang-language-standard RET "gnu99"ます。
標準をグローバルに設定するには、C モード フックを使用して各バッファに値を設定します。
(defun my-flycheck-c-setup ()
(setq flycheck-clang-language-standard "gnu99"))
(add-hook 'c-mode-hook #'my-flycheck-c-setup)
グローバル値の変更には使用しないでください。setq-default
C++ ファイルを編集すると壊れます。