我使用Flycheck已经有一段时间了,但我不知道如何使它正确识别杂乱。我根据我找到的一个教程,将这个(非常简单的)程序键入Emacs:

#include <stdlib.h>
#include <clutter/clutter.h>

//draws a basic, black window
int main(int argc, char *argv[])
{
  ClutterInitError e = clutter_init(&argc, &argv); //pass it any
                                               //options - these
                                               //can be fed
  if (e == CLUTTER_INIT_SUCCESS) {
    ClutterColor stage_color = {0, 0, 0, 255}; //RGBA [0, 255]
    ClutterActor *stage = clutter_stage_new();
    clutter_actor_set_size(stage, 512, 512);
    clutter_actor_set_background_color(stage, &stage_color);
    clutter_actor_show(stage);
    clutter_main();
    return EXIT_SUCCESS;
  } else {
    return 1;
  }
}

现在,在第2行(the#include <clutter/clutter.h>),我收到了Flycheck关于找不到clutter/clutter.h的警告。很公平-在编译器中,我需要使用pkg-config来成功编译它。在我的系统上,pkg-config clutter-1.0 --cflags --libs输出:
-pthread -I/usr/include/clutter-1.0 -I/usr/include/pango-1.0 -I/usr/include/cogl -I/usr/include/cairo -I/usr/include/atk-1.0 -I/usr/include/pango-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/freetype2 -I/usr/include/harfbuzz -I/usr/include/libpng16 -I/usr/include/cogl -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/libdrm -I/usr/include/json-glib-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -lclutter-1.0 -lcogl-path -lcairo-gobject -latk-1.0 -lpangocairo-1.0 -lpango-1.0 -lcairo -lcogl-pango -lcogl -lgmodule-2.0 -pthread -lgdk_pixbuf-2.0 -lwayland-egl -lgbm -ldrm -lEGL -lXrandr -ljson-glib-1.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lwayland-cursor -lwayland-client -lxkbcommon -lwayland-server -lX11 -lXext -lXdamage -lXfixes -lXcomposite -lXi

现在,我有点傻了(也有点傻了),所以忍受我吧。我知道我需要使用M-x customize-group flycheck-options,在那里,我需要把一些东西放到Flycheck GCC Include PathFlycheck GCC Includes中。但是,我不知道上面输出的哪一部分(如果有的话)去了哪里?我真的很感谢你的帮助,所以,当我和其他图书馆一起工作时,我会知道如何正确地设置它们。

最佳答案

-I输出中,所有前缀为pkg-config clutter-1.0 --cflags --libs的路径都是包含路径。
明确地:

/usr/include/clutter-1.0
/usr/include/pango-1.0
/usr/include/cogl
/usr/include/cairo
/usr/include/atk-1.0
/usr/include/pango-1.0
/usr/include/cairo
/usr/include/pixman-1
/usr/include/freetype2
/usr/include/libpng16
/usr/include/harfbuzz
/usr/include/freetype2
/usr/include/harfbuzz
/usr/include/libpng16
/usr/include/cogl
/usr/include/gdk-pixbuf-2.0
/usr/include/libpng16
/usr/include/libdrm
/usr/include/json-glib-1.0
/usr/include/glib-2.0
/usr/lib/glib-2.0/include

将它们添加到Flycheck GCC Include Path

关于c - Flycheck和Clutter-如何设置?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26009905/

10-11 18:02