I'm using emacs with flycheck to check C source code syntax and trying to get it working with glib. My code compiles and runs correctly, however flycheck reports a file not found error in the #include <glib.h>
line and stops reporting further errors, defeating its purpose.
Here's my sample source file:
#include <stdio.h>
#include <glib.h>
GList* list = NULL;
int main() {
list = g_list_append(list, "a");
list = g_list_append(list, "b");
list = g_list_append(list, "c");
for ( ; list!=NULL; list=list->next) {
printf("%s\n", (char*)list->data);
}
return 0;
}
And the makefile
P=glist
OBJECTS=
CFLAGS=-g -Wall -O3 `pkg-config --cflags glib-2.0`
LDLIBS=`pkg-config --libs glib-2.0`
CC=gcc-4.9
$(P): $(OBJECTS)
If I change the include line to read #include <glib-2.0/glib.h>
I get the following error reported in the minibuffer:
Checker c/c++-clang returned non-zero exit code 1, but no errors from output: In file included from /var/folders/f/ts3zs3cjbq1fqfhdfrl1w0000gn/T/flycheck87881gVK/glist.c:2: /usr/local/include/glib-2.0/glib.h:32:10: error: 'glib/galloca.h' file not found with include; use "quotes" instead In file included from /var/folders/_f/ts3_zs3cjbq1fqfhdfrl1w0000gn/T/flycheck87881gVK/glist.c:2: In file included from /usr/local/include/glib-2.0/glib.h:32: /usr/local/include/glib-2.0/glib/galloca.h:34:10: fatal error: 'glib/gtypes.h' file not found
Checker definition probably flawed.
Still the code compiles and runs correctly. I'm not sure why it can't find glib/gtypes.h
as it exists under one of the included directories. The output from pkg-config --cflags glib-2.0
is:
-I/usr/local/Cellar/glib/2.36.4/include/glib-2.0 -I/usr/local/Cellar/glib/2.36.4/lib/glib-2.0/include -I/usr/local/opt/gettext/include
Listing ls /usr/local/Cellar/glib/2.36.4/include/glib-2.0/glib/gtypes.h
/usr/local/Cellar/glib/2.36.4/include/glib-2.0/glib/gtypes.h
And listing ls /usr/local/include/glib-2.0/glib/gtypes.h
/usr/local/include/glib-2.0/glib/gtypes.h
So the file is there. I wouldn't mind switching to flymake if flycheck is to blame, but I'm not sure if it's a problem with my setup or flycheck itself. Plus flycheck configuration is dead simple and otherwise works very well. I'm using version 20130904.2245 installed from elpa.