Skip to content

Instantly share code, notes, and snippets.

@mooz
Created December 18, 2011 15:04
Show Gist options
  • Save mooz/1493649 to your computer and use it in GitHub Desktop.
Save mooz/1493649 to your computer and use it in GitHub Desktop.
My flymake settings for C/C++
;; just an example
((c++-mode . ((flymake-additional-compilation-flags . ("-I../" "-std=c++0x")))))
(defvar flymake-additional-compilation-flags nil)
(put 'flymake-additional-compilation-flags 'safe-local-variable 'listp)
;; no need to arrange Makefile
(defun flymake-cc-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name)))
(common-args (append (list "-Wall" "-W" "-fsyntax-only" local-file)
flymake-additional-compilation-flags)))
(if (eq major-mode 'c++-mode)
(list "g++" common-args)
(list "gcc" common-args))))
(loop for ext in '("\\.c$" "\\.h$" "\\.cc$" "\\.cpp$" "\\.hh$")
do
(push `(,ext flymake-cc-init) flymake-allowed-file-name-masks))
(add-hook 'c-mode-hook (lambda () (flymake-mode t)))
(add-hook 'c++-mode-hook (lambda () (flymake-mode t)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment