flycheck / flycheck

On the fly syntax checking for GNU Emacs
https://www.flycheck.org
GNU General Public License v3.0
2.4k stars 448 forks source link

clang marking as error header from external library #1188

Closed pinkfloydsito closed 7 years ago

pinkfloydsito commented 7 years ago

I am trying to configure the c/c++-clang linter for checking syntax in my project which uses gtk. But currently it does not check my syntax, it keeps hanging in the first line showing the error message

  In include /usr/include/gtk-3.0/gtk/gtk.h (c/c++-clang)

When i run flycheck-compile I get the following output:

clang -fsyntax-only -fno-color-diagnostics -fno-caret-diagnostics -fno-diagnostics-show-option -iquote /root/Projects/C-pomodoro/ -Wall -Wextra -I /usr/include/gtk-3.0/gtk -I /usr/include/gtk-3.0/gdk -x c - < /root/Projects/C-pomodoro/main.c In file included from :1: /usr/include/gtk-3.0/gtk/gtk.h:30:10: fatal error: 'gdk/gdk.h' file not found

pinkfloydsito commented 7 years ago

Well, today I decided to use gcc instead of clang and add the output from pkg-config to the gcc command (That was recommended) The command runs fine when I execute it from the command line, but when I try to check the syntax using flycheck it shows the following output:

gcc -fshow-column -fno-diagnostics-show-caret -fno-diagnostics-show-option -iquote /root/Projects/C-pomodoro/ -Wall -Wextra -pthread\ -I/usr/include/gtk-3.0\ -I/usr/include/at-spi2-atk/2.0\ -I/usr/include/at-spi-2.0\ -I/usr/include/dbus-1.0\ -I/usr/lib/dbus-1.0/include\ -I/usr/include/gtk-3.0\ -I/usr/include/gio-unix-2.0/\ -I/usr/include/cairo\ -I/usr/include/pango-1.0\ -I/usr/include/atk-1.0\ -I/usr/include/cairo\ -I/usr/include/pixman-1\ -I/usr/include/freetype2\ -I/usr/include/libpng16\ -I/usr/include/harfbuzz\ -I/usr/include/glib-2.0\ -I/usr/lib/glib-2.0/include\ -I/usr/include/freetype2\ -I/usr/include/harfbuzz\ -I/usr/include/libdrm\ -I/usr/include/libpng16\ -I/usr/include/gdk-pixbuf-2.0\ -I/usr/include/libpng16\ -I/usr/include/glib-2.0\ -I/usr/lib/glib-2.0/include\ -lgtk-3\ -lgdk-3\ -lpangocairo-1.0\ -lpango-1.0\ -latk-1.0\ -lcairo-gobject\ -lcairo\ -lgdk_pixbuf-2.0\ -lgio-2.0\ -lgobject-2.0\ -lglib-2.0 -x c -S -o /dev/null - < /root/Projects/C-pomodoro/main.c gcc: error: unrecognized command line option ‘-pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/harfbuzz -I/usr/include/libdrm -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0

The problem is the format in which the clang-args have been addded in my .local-dirs.el file

This is what I have in my .local-dirs.el file

((c-mode .
         (
          ;; (setq-local command "pkg-config")
          ;; (setq-local command (concat command " --cflags gtk+-3.0 " " --libs gtk+-3.0"))
          ;; (setq-local include-args (shell-command-to-string command))
          (flycheck-clang-args . "-pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/harfbuzz -I/usr/include/libdrm -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0") ) ) )

This is the command I run from the command line:

gcc -fshow-column -fno-diagnostics-show-caret -fno-diagnostics-show-option -iquote /root/Projects/C-pomodoro/ -Wall -Wextra -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/harfbuzz -I/usr/include/libdrm -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -x c -S -o /dev/null - < /root/Projects/C-pomodoro/main.c

It does check properly the syntax from command line. How can I fix this?

cpitclaudel commented 7 years ago

flycheck-clang-args should be a list, not a string :)