简体   繁体   English

GTK 3.0给编译器错误“仅 <gdk/gdkh> 可以直接包含在内”

[英]GTK 3.0 gives compiler error “Only <gdk/gdkh> can be included directly”

Working on a GTK++ project. 正在从事GTK ++项目。 The thing compiled successfully when using Ubuntu's libgtk2.0-dev library. 使用Ubuntu的libgtk2.0-dev库时,该编译成功。 After removing that library and installing libgtk3.0-dev library, I get the following error message at compile time: 删除该库并安装libgtk3.0-dev库后,在编译时出现以下错误消息:

In file included from file_operations.c:4:0:
/usr/include/gtk-3.0/gdk/gdkevents.h:26:2 #error: Only <gdk/gdkh> can be included directly.

Here is the compile command: 这是编译命令:

gcc -Wall -o gexplorer2 main.c file_operations.c -I. -I/usr/include/gnome-vfs-2.0 -D _FILE_OFFSET_BITS=64 `pkg-config --cflags gtk+-3.0` `pkg-config --libs gtk+-3.0` `pkg-config --cflags gio-2.0`

file_operations.c has the following includes: file_operations.c具有以下内容:

#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <gdk/gdkkeysyms.h>
#include <gdk/gdkevents.h>

In gdkevents.h, the following lines generate the compiler error 在gdkevents.h中,以下几行生成编译器错误

#if !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
#error "Only <gdk/gdkh> can be included directly."
#endif

(These lines were not in GTK 2.0's include files.) (这些行不在GTK 2.0的包含文件中。)

Guesses or knowledge on what is causing this error, and how to resolve? 猜测或知识是什么导致此错误,以及如何解决?

The idea here seems to be that the GDK authors want to discourage you from including specific GDK headers directly (presumably because those headers have subtle dependencies that are not spelled out with explicit includes). 这里的想法似乎是GDK作者不鼓励您直接包含特定的GDK标头(大概是因为这些标头具有细微的依赖关系,而这些显式的依赖关系没有用明确的include拼写出来)。

So just do what they say, remove your <gdk/x> includes and include <gdk/gdkh> instead. 因此,按照他们说的去做,删除<gdk/x>包含项,而改为包含<gdk/gdkh> Presumably, that should include the APIs you want. 大概应该包括您想要的API。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM