cgccgnomemate-desktop

"expected declaration specifiers" on Make with GCC


I am trying to port https://github.com/alexkay/xmonad-log-applet from GNOME2 to MATE, and so far I have gotten past configuration etc and I am trying to build. You can find my modifications here: https://github.com/geniass/xmonad-log-applet. When I run make, it starts building, but on the last line it gives these errors:

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

I've seen quite a few similar questions here on stackoverflow, but they have mostly been about leaving out curly braces or method prototype return types. I can't see any here, but maybe I've just missed one? Apart from that possibility, I have absolutely no idea what could be wrong; these errors are totally meaningless to me

Here's main.c with the ifdef's removed for clarity (gives the same errors):

#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: %s\n", 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);

Solution

  • Turns out I was just using an old version of the libmatepanel library. I was using 2.0 whereas the current version is 3.0. For some reason I have both on my system