2

In my .dir-locals.el I have:

(cpp-mode . (setq flycheck-gcc-include-path '("/home/<user>/<project>/include")))

This doesnt seem to set flycheck-gcc-include-path, any ideas why?

Also is there a list option for flycheck-gcc-include-path so I can specify more than one include directory?

Edit: Heres my flycheck stuff in my init.el:

;; syntax checker flycheck
(add-hook 'after-init-hook #'global-flycheck-mode)
; error showing up console
(with-eval-after-load 'flycheck
  (flycheck-pos-tip-mode))
;(setq flycheck-gcc-include-path '("/home/<user>/<project>"))
(setq flycheck-disabled-checkers '(c/c++-clang))
(setq flycheck-enabled-checkers '(c/c++-gcc))

If I uncomment the line for flycheck-gcc-include-path it works. I want this on a project basis so I am trying to set it in .dir-locals.el

4

I see a few potential issues:

  1. I am not familiar with a cpp-mode; I assume you mean c++-mode.
  2. The contents of a dir-locals-file should form an alist, i.e. ((mode . vars)) instead of (mode . vars).
  3. The cdr of each such mode-vars pair, i.e. the mode-specific settings, should also form an alist: ((mode . ((var . val)))) instead of ((mode . (var . val))).
  4. Each variable-value pair results in the cdr (value) being assigned to the car (variable); the form is not evaluated as is. The cdr is only evaluated when the car comprises the special symbol eval.

So, your dir-locals-file should probably read:

((c++-mode . ((flycheck-gcc-include-path . ("/home/<user>/<project>/include")))))

See the following info manual nodes for more information:

Also is there a list option for flycheck-gcc-include-path so I can specify more than one include directory?

As far as I can tell from the variable's documentation (C-h v flycheck-gcc-include-path RET) it is supposed to be a list of directory paths. If this does not work you should consider reporting it as a bug.

  • Your solution worked thank you, I actually had c++-mode in my .dir i probably changed it at some point.Your point #3 did the trick. The mode and variable were supposed to form an alist! I have a question that the wiki seems to neglect. What are the . for ? – sp00kyb00g13 May 23 '17 at 22:02
  • The dots are due to the standard dotted pair notation for cons cells. See here and its subnode "Dotted Pair Notation" for more information. – Basil May 23 '17 at 23:32
  • @sp00kyb00g13 See also here and here from the Intro to Elisp manual. – Basil May 23 '17 at 23:34
  • @sp00kyb00g13 See also this and this from the Elisp manual. These last four links are in case you are not yet particularly familiar with cons cells and lists. – Basil May 23 '17 at 23:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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