Skip to content

Instantly share code, notes, and snippets.

@phikal
Forked from mooz/.dir-locals.el
Last active April 17, 2022 11:48
Show Gist options
  • Save phikal/2e7dc35423be1ebf891637c9329203a9 to your computer and use it in GitHub Desktop.
Save phikal/2e7dc35423be1ebf891637c9329203a9 to your computer and use it in GitHub Desktop.
My flymake settings for C/C++
;; just an example
((c++-mode . ((flymake-additional-clang-flags . ("-I../" "-std=c++0x")))))
(require 'flymake)
(defvar flymake-additional-clang-flags nil)
(put 'flymake-additional-clang-flags 'safe-local-variable 'listp)
;; no need to arrange Makefile
(defun flymake-cc-init ()
`("clang"
("-fsyntax-only" "-Weverything"
,@flymake-additional-clang-flags
,(file-name-nondirectory
(flymake-proc-init-create-temp-buffer-copy
'flymake-create-temp-inplace)))))
;; (push (list (rx "." (or "c" "h" "cc" "cpp" "hh") eos)
;; #'flymake-cc-init)
;; flymake-proc-allowed-file-name-masks)
;; (add-hook 'c-mode-hook #'flymake-mode)
;; (add-hook 'c++-mode-hook #'flymake-mode)
@phikal
Copy link
Author

phikal commented Apr 17, 2022

With a recent enough version of Flymake, all you have to do is to set flymake-cc-command like

(setq flymake-cc-command `("clang" "-fsyntax-only" "-Weverything" "-x" "c" "-"))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment