c语言 - "expected declaration specifiers" on Made with GCC



我正在尝试将https://github.com/alexkay/xmonad-log-applet从GNOME2移植到MATE,到目前为止,我已经完成了配置等,我正在尝试构建。你可以在这里找到我的修改:https://github.com/geniass/xmonad-log-applet。当我运行make时,它开始构建,但在最后一行它给出了这些错误:

main.c:92:39: error: expected declaration specifiers or ‘...’ before string constant
main.c:92:65: error: expected declaration specifiers or ‘...’ before ‘(’ token
main.c:92:84: error: expected declaration specifiers or ‘...’ before string constant
main.c:92:103: error: expected declaration specifiers or ‘...’ before ‘xmonad_log_applet_factory’
main.c:92:130: error: expected declaration specifiers or ‘...’ before ‘(’ token

我在stackoverflow上看到过很多类似的问题,但它们大多是关于省略花括号或方法原型返回类型的。我在这里看不到,但也许我错过了一个?除了这种可能性,我完全不知道哪里出了问题;这些错误对我来说完全没有意义

下面是main.c为了清晰起见删除了ifdef(给出相同的错误):

#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include <dbus/dbus-glib.h>
#include <mate-panel-applet.h>
static void signal_handler(DBusGProxy *obj, const char *msg, GtkWidget *widget)
{
    gtk_label_set_markup(GTK_LABEL(widget), msg);
}
static void set_up_dbus_transfer(GtkWidget *buf)
{
    DBusGConnection *connection;
    DBusGProxy *proxy;
    GError *error= NULL;
    connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
    if(connection == NULL) {
        g_printerr("Failed to open connection: %sn", error->message);
        g_error_free(error);
        exit(1);
    }
    proxy = dbus_g_proxy_new_for_name(
        connection, "org.xmonad.Log", "/org/xmonad/Log", "org.xmonad.Log");
    error = NULL;
    dbus_g_proxy_add_signal(proxy, "Update", G_TYPE_STRING, G_TYPE_INVALID);
    dbus_g_proxy_connect_signal(
        proxy, "Update", (GCallback)signal_handler, buf, NULL);
}
static gboolean xmonad_log_applet_fill(MatePanelApplet *applet)
{
    mate_panel_applet_set_flags(
        applet,
        MATE_PANEL_APPLET_EXPAND_MAJOR |
        MATE_PANEL_APPLET_EXPAND_MINOR |
        MATE_PANEL_APPLET_HAS_HANDLE);
    mate_panel_applet_set_background_widget(applet, GTK_WIDGET(applet));
    GtkWidget *label = gtk_label_new("Waiting for Xmonad...");
    gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_END);
    gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
    gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
    set_up_dbus_transfer(label);
    gtk_container_add(GTK_CONTAINER(applet), label);
    gtk_widget_show_all(GTK_WIDGET(applet));
    return TRUE;
}
static gboolean xmonad_log_applet_factory(
    MatePanelApplet *applet, const gchar *iid, gpointer data)
{
    gboolean retval = FALSE;
    if(!strcmp(iid, "XmonadLogApplet"))
        retval = xmonad_log_applet_fill(applet);
    if(retval == FALSE) {
        printf("Wrong applet!n");
        exit(-1);
    }
    return retval;
}
MATE_PANEL_APPLET_OUT_PROCESS_FACTORY("XmonadLogAppletFactory", PANEL_TYPE_APPLET, "XmonadLogApplet", xmonad_log_applet_factory, NULL);

看起来您错过了提供MATE_PANEL_APPLET_OUT_PROCESS_FACTORY定义的包含

原来我只是在使用旧版本的libmatpanel库。我使用的是2.0,而当前的版本是3.0。由于某些原因,我的系统中都有

最新更新