Flycheck help

From OpenCog
Jump to: navigation, search

Overview

flycheck is an emacs mode to compile check you code as you type. It supports many languages out of the box. However you need some configuration to support C++11.

Configuration

Configure emacs for flycheck

To use flycheck for opencog just add the following lines in your emacs config file (after installing it of course, flycheck is not yet included in emacs)

(require 'flycheck)
(add-hook 'after-init-hook #'global-flycheck-mode)

Scheme

Flycheck supports Scheme out-of-the-box, you just need to install Chicken and the emacs package Geiser.

C++

Add C++11 support for gcc

I found gcc works better than clang for compile checking. The following code disable clang and add C++11 support for gcc.

; Disable clang check, gcc check works better
(setq-default flycheck-disabled-checkers
	      (append flycheck-disabled-checkers
		      '(c/c++-clang)))

; Enable C++11 support for gcc
(add-hook 'c++-mode-hook (lambda () (setq flycheck-gcc-language-standard "c++11")))

Add support for cxxtest files

If you wish to have flycheck work for cxxtest file just add the following in your emacs config file

;; Open cxxtest in C++ mode
(setq auto-mode-alist (cons '("\\.cxxtest$" . c++-mode) auto-mode-alist))

Additionally you may need to add the following include in the cxxtest file.

#include <cxxtest/TestSuite.h>