我正在尝试在 VS2012 中编译一个简单的 GTK+ C 程序。在让 GTK+ 在 VS2012 中工作后,我决定尝试一个简单的程序,看看它是否能正确编译和运行。我遇到了一些编译错误,我确信可以解决我只是不知道如何解决它们。这是我的来源:
#include <gtk/gtk.h>
static void destroy(GtkWidget *widget, gpointer data)
{
gtk_main_quit();
}
int main(int argc, char *argv[])
{
gtk_init(&argc, &argv);
GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "Window");
g_signal_connect(window, "destroy", G_CALLBACK(destroy), NULL);
gtk_widget_show_all(window);
gtk_main();
return 0;
}
这些是我得到的错误:
+-------+---+----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------+----+---+------------------+
| Error | 1 | error C2275: 'GtkWidget' : illegal use of this type as an expression | c:\users\pr0d1gy\documents\visual studio 2012\projects\cassemblyexample\cassemblyexample\source.c | 10 | 1 | CAssemblyExample |
| Error | 2 | error C2065: 'window' : undeclared identifier | c:\users\pr0d1gy\documents\visual studio 2012\projects\cassemblyexample\cassemblyexample\source.c | 10 | 1 | CAssemblyExample |
| Error | 3 | error C2065: 'window' : undeclared identifier | c:\users\pr0d1gy\documents\visual studio 2012\projects\cassemblyexample\cassemblyexample\source.c | 11 | 1 | CAssemblyExample |
| Error | 4 | error C2065: 'window' : undeclared identifier | c:\users\pr0d1gy\documents\visual studio 2012\projects\cassemblyexample\cassemblyexample\source.c | 12 | 1 | CAssemblyExample |
| Error | 6 | error C2065: 'window' : undeclared identifier | c:\users\pr0d1gy\documents\visual studio 2012\projects\cassemblyexample\cassemblyexample\source.c | 13 | 1 | CAssemblyExample |
+-------+---+----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------+----+---+------------------+