gergelypolonkai-web-jekyll/_posts/2014-08-16-registering-an-enum-type-in-glib-glib-mkenums-magic.markdown
Gergely Polonkai 2f61b11a5a Move post code chunks to Gists
Also, remove highlight specific things from style.sass
2015-04-27 11:08:14 +02:00

1.3 KiB

layout title date tags permalink published author
post Registering an enum type in GLib, glib-mkenums magic 2014-08-16 15:10:54+00:00
development
c
glib
/blog/2014/8/16/registering-an-enum-type-in-glib-glib-mkenums-magic true
name email
Gergely Polonkai gergely@polonkai.eu

In this post I said I will get through the GLib Makefiles to add an enum type to GLib in a more sophisticated way.

In my other project, SWE-GLib I already used this method. The following two rules in Makefile.am create gswe-enumtypes.h and gswe-enumtypes.c.

{% gist gergelypolonkai/1e2fdedb136de3ca67f0 Makefile %}

$(GLIB_MKENUMS) is set in configure with AC_PATH_PROG([GLIB_MKENUMS], [glib-mkenums]).

This approach requires the GNU Autotools (you can get rid of it by changing $(GLIB_MKENUMS) to the path to glib-mkenums binary), and two template files, one for the header and one for the code. $(gswe_enum_headers) contains a list of all the header files that have enum types defined throughout the project.

{% gist gergelypolonkai/1e2fdedb136de3ca67f0 gswe-enumtypes.h %}

{% gist gergelypolonkai/1e2fdedb136de3ca67f0 gswe-enumtypes.c %}