当写简单,一个文件,C ++代码,我通常称之为克++直接。 默认情况下,Flymake似乎假定一个Makefile的存在与检查语法目标。 如何配置Flymake只需拨打G ++直接,如:
g++ -c a.cpp
如果答案可以被修改,以包括编译器标志,这将是更好
非常感谢
当写简单,一个文件,C ++代码,我通常称之为克++直接。 默认情况下,Flymake似乎假定一个Makefile的存在与检查语法目标。 如何配置Flymake只需拨打G ++直接,如:
g++ -c a.cpp
如果答案可以被修改,以包括编译器标志,这将是更好
非常感谢
你可以G ++直接与下面的flymake配置调用。
(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)
我得到了下面的截图当我打电话flymake-allowed-file-name-masks
以下是评论的版本。
;; Import flymake
(require 'flymake)
;; Define function
(defun flymake-cc-init ()
(let* (;; Create temp file which is copy of current file
(temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
;; Get relative path of temp file from current directory
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
;; Construct compile command which is defined list.
;; First element is program name, "g++" in this case.
;; Second element is list of options.
;; So this means "g++ -Wall -Wextra -fsyntax-only tempfile-path"
(list "g++" (list "-Wall" "-Wextra" "-fsyntax-only" local-file))))
;; Enable above flymake setting for C++ files(suffix is '.cpp')
(push '("\\.cpp$" flymake-cc-init) flymake-allowed-file-name-masks)
;; Enable flymake-mode for C++ files.
(add-hook 'c++-mode-hook 'flymake-mode)