Search code examples
gtk3glibgobject

G_DECLARE_FINAL_TYPE() throws compiler error


I have written a programm in C and GTK3. I am using Arch Linux and everything works fine. However, I have to use my program also on a rather old Ubuntu machine.

  • gtk+-3.0 3.10.8
  • GCC 4.8.4

With this setup the program does not compile In the Header file of a custom GTK-Widget I have:

#ifndef __LAYER_ELEMENT_H__
#define __LAYER_ELEMENT_H__

#include <gtk/gtk.h>
G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE(LayerElement, layer_element, LAYER, ELEMENT, GtkListBoxRow)

/* Rest of file comes here */

When compiling it throws the error message: expected ')' before GtkListBoxRow in the line with the G_DECLARE_FINAL_TYPE macro.

How can I fix this issue?


Solution

  • G_DECLARE_FINAL_TYPE was added to GLib in version 2.44 (see the documentation). If you want to compile on an old version of Ubuntu, you will either have to get hold of a backport of GLib 2.44 (or later) for that version of Ubuntu, and compile against that; or you will have to modify your code to not use any GLib APIs added after version 2.40.