I am attempting to use Directory-Variables in order to set the flycheck-gcc-language-standard variable. I used: M-x add-dir-local-variable RET c++-mode RET flycheck-gcc-language-standard RET "c++11" to create the .dir-local.el file in the project root directory. Which results in the following code:

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

the above creates a warning that this is a "malformed function". I've tried several variations: without quotes, c++0x instead of c++11, among others. Flycheck.el doesn't list what are acceptable variables. I'm stuck.

Any suggestions would be very much appreciated.

If it helps below is the debugger output:

Debugger entered--Lisp error:
(invalid-function (c++-mode (flycheck-gcc-language-standard . c++11)))
((c++-mode (flycheck-gcc-language-standard . c++11)))
eval(((c++-mode (flycheck-gcc-language-standard . c++11))) nil)
funcall-interactively(eval-last-sexp nil)
call-interactively(eval-last-sexp nil nil)

It seems to me that I'm missing something but I don't know it might be. I new to emacs.

2 Answers 2


There is nothing wrong here except that flycheck is giving you a bogus warning because it is seeing c++mode as a function. But a dir-locals.el file just holds a specially-constructed list, which maps major mode names (symbols) to alists.


In addition to the explanation by Christopher Gray, you can append the following to your .dir-locals.el files to avoid the spurious warnings.

;; Local Variables: 
;; eval: (flycheck-mode -1) 
;; End: 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.