I am trying to get syntax highlighting for C++ code working in Emacs using flymake. I know that with the standard flymake configuration for C++ it will try and run make syntax-check
, however, my build system does not use a Makefile (or at least not directly). It uses rosmake which is a wrapper over cmake for the ROS system.
In order to get around the fact that I don't have control over the Makefile I've been trying to add a custom flymake checker based on the flymake website and this stackoverflow question.
I've created the command g++ -Wall -Wextra -fsyntax-only -Iinclude_dir file_to_check.cpp
. When I run the command in bash I get the expected output. With no syntax errors I have an exit code 0 and no output. With syntax errors I have an exit code 1 and errors listed by line. However, whenever I try to run this with flymake I get a CFGERR and am told that flymake has been disabled.
I'm pretty sure that the correct command is running because the error displays the full command and everything looks the same as what I type in the terminal. I turned the logging level all the way up to 3 in order to see what the problem is. There is an error about halfway through the log
file /home/rhololkeolke/ros_workspace/team-hku-drc/robot_code/state_trigger/src/Broadcaster.cpp, init=flymake-cc-init [3 times]
create-temp-inplace: file=/home/rhololkeolke/ros_workspace/team-hku-drc/robot_code/state_trigger/src/Broadcaster.cpp temp=/home/rhololkeolke/ros_workspace/team-hku-drc/robot_code/state_trigger/src/Broadcaster_flymake.cpp
saved buffer Broadcaster.cpp in file /home/rhololkeolke/ros_workspace/team-hku-drc/robot_code/state_trigger/src/Broadcaster_flymake.cpp
started process 14517, command=(g++ -Wall -Wextra -fsyntax-only -std=c++0x -I/home/rhololkeolke/ros_workspace/team-hku-drc/robot_code/state_trigger/include -I/home/rhololkeolke/ros_workspace/team-hku-drc/robot_code/state_trigger/msg_gen/cpp/include -I/home/rhololkeolke/ros_workspace/team-hku-drc/robot_code/state_trigger/srv_gen/cpp/include -I/opt/ros/fuerte/include
Broadcaster_flymake.cpp), dir=/home/rhololkeolke/ros_workspace/team-hku-drc/robot_code/state_trigger/src/
received 40 byte(s) of output from process 14517
file /home/rhololkeolke/ros_workspace/team-hku-drc/robot_code/state_trigger/src/Broadcaster.cpp, init=flymake-cc-init
parsed 'g++: error: : No such file or directory', no line-err-info
file /home/rhololkeolke/ros_workspace/team-hku-drc/robot_code/state_trigger/src/Broadcaster.cpp, init=flymake-cc-init
process 14517 exited with code 1
cleaning up using flymake-simple-cleanup
deleted file /home/rhololkeolke/ros_workspace/team-hku-drc/robot_code/state_trigger/src/Broadcaster_flymake.cpp
Broadcaster.cpp: 0 error(s), 0 warning(s), 0 info in 0.07 second(s)
switched OFF Flymake mode for buffer Broadcaster.cpp due to fatal status CFGERR, warning Configuration error has occured while running (g++ -Wall -Wextra -fsyntax-only -std=c++0x -I/home/rhololkeolke/ros_workspace/team-hku-drc/robot_code/state_trigger/include -I/home/rhololkeolke/ros_workspace/team-hku-drc/robot_code/state_trigger/msg_gen/cpp/include -I/home/rhololkeolke/ros_workspace/team-hku-drc/robot_code/state_trigger/srv_gen/cpp/include -I/opt/ros/fuerte/include
Broadcaster_flymake.cpp)
The main error appears to be parsed 'g++: error: : No such file or directory', no line-err-info
. I thought it might be because the Broadcaster_flymake.cpp never got created but I checked that and it seems to be working. I get these errors regardless of whether or not there is a syntax error. I can't figure out why it can't find the file as copying and pasting the command into Bash works perfectly. I also tried (shell-command "g++")
in an buffer just to make sure that emacs was finding the g++ binary and it is.
If you have any idea why flymake is failing to run the command please let me know. Thank you.