Configure Emacs Flymake to call g++ directly -
when writing simple, 1 file, c++ code, phone call g++ directly. default, flymake seems assume presence of makefile check-syntax target. how configure flymake phone call g++ directly, e.g:
g++ -c a.cpp
if reply modified include compiler flags, better
many thanks
you can phone call g++ straight next flymake configuration.
(require 'flymake) (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)))) (list "g++" (list "-wall" "-wextra" "-fsyntax-only" local-file)))) (push '("\\.cpp$" flymake-cc-init) flymake-allowed-file-name-masks) (add-hook 'c++-mode-hook 'flymake-mode)
i got next screenshot when phone call flymake-allowed-file-name-masks
following comment version.
;; import flymake (require 'flymake) ;; define function (defun flymake-cc-init () (let* (;; create temp file re-create of current file (temp-file (flymake-init-create-temp-buffer-copy 'flymake-create-temp-inplace)) ;; relative path of temp file current directory (local-file (file-relative-name temp-file (file-name-directory buffer-file-name)))) ;; build compile command defined list. ;; first element programme name, "g++" in case. ;; sec element list of options. ;; means "g++ -wall -wextra -fsyntax-only tempfile-path" (list "g++" (list "-wall" "-wextra" "-fsyntax-only" local-file)))) ;; enable above flymake setting c++ files(suffix '.cpp') (push '("\\.cpp$" flymake-cc-init) flymake-allowed-file-name-masks) ;; enable flymake-mode c++ files. (add-hook 'c++-mode-hook 'flymake-mode)
emacs flymake
No comments:
Post a Comment