emacs for c++ on windows
irony모드를 이용하기위해서 clang이 필요하지만, 컴파일과 디버깅은 gcc와 gdb를 이용할 계획입니다.
https://github.com/Sarcasm/irony-mode/wiki/Setting-up-irony-mode-on-Windows
1. CMake, Clang(LLVM), mingw-w64 설치합니다(all 32bit)
https://cmake.org/download/
http://releases.llvm.org/download.html
https://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/
2. irony-mode, company-irony, irony-eldoc package에서 설치
irony mode인 버퍼에서 X-x irony-install-server
VS가 설치되어있지 않은 경우 Visual C++ Build Tools 2015를 설치해줍니다.
http://landinghub.visualstudio.com/visual-cpp-build-tools
이 경우 clang은 3.7.1 이하의 버전을 설치하여야 clang이 gcc를 이용해 compile하며, clang 최신버전을 사용할 경우 msvc컴파일러가 존재하도록 visual studio 2015 community를 설치해주면 4.0.1 clang을 사용할 수 있습니다.
visual studio 2015 community
https://imagine.microsoft.com/en-us/Catalog/Product/101
3. emacs에 다음을 추가합니다
;;c/cpp settings
(mapc (lambda (mode)
(let ((hook (intern (concat (symbol-name mode)
"-mode-hook"))))
;;(add-hook hook (lambda () (autopair-mode 1)))
(add-hook hook (lambda () (irony-mode 1)))
(add-hook hook (lambda () (add-to-list 'company-backends 'company-irony)))
(add-hook hook (lambda () (irony-eldoc 1)))
))
'(c c++))
(add-hook 'c-mode-hook
(lambda ()
(set (make-local-variable 'compile-command)
(let ((file (file-name-nondirectory buffer-file-name)))
(format "%s %s -o %s.exe -g"
"gcc"
file
(file-name-sans-extension file))))))
(add-hook 'c++-mode-hook
(lambda ()
(set (make-local-variable 'compile-command)
(let ((file (file-name-nondirectory buffer-file-name)))
(format "%s %s -o %s.exe -g"
"g++"
file
(file-name-sans-extension file))))))
;;(add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)
;;for irony in windows
(yas-global-mode 1)
(when (boundp 'w32-pipe-read-delay)
(setq w32-pipe-read-delay 0))
;; Set the buffer size to 64K on Windows (from the original 4K)
(when (boundp 'w32-pipe-buffer-size)
(setq irony-server-w32-pipe-buffer-size (* 64 1024)))