Murray's Blog

Avoiding Use of Deprecated API

Most Deprecated GTK+ 2 API is not in GTK+ 3

GTK+ 3 has API changes compared to GTK+ 2, but some of the new API has been added to GTK+ 2.22 and 2.24, and older API has been deprecated. gtkmm has done this too. This is intended to ease porting to GTK+ 3 (or gtkmm 3). If your application builds with GTK+ 2.24 with deprecated API disabled then it will be much easier to port to GTK+ 3 afterwards.

This requires defining C macros such as GTK_DISABLE_DEPRECATED, though you’ll want to use GDK_DISABLE_DEPRECATED, GDK_PIXBUF_DISABLE_DEPRECATED, G_DISABLE_DEPRECATED and maybe PANGO_DISABLE_DEPRECATED too. You can specify these as -D options in your

However, you should not disable deprecated API in your build at all times. That just makes life unnecessarily difficult for people building from tarballs.

So over the last few years, Daniel Elstner has perfected an MM_ARG_ENABLE_WARNINGS m4 macro for use with autotools. It adds an –enable-warnings=min/max/fatal/no configure option. We use it mostly to turn on compiler-warnings-as-errors, but I think that it would be very useful to many people now during the transition to GTK+ 3.


This macro is in mm-common, which you could depend on, though it contains other stuff that is only interesting to gtkmm projects. For instance, I use it in Glom’s file, like so:

  [-Wall -Wextra -Wno-missing-field-initializers -DGSEAL_ENABLE],

I then use the resulting variable in my file, like so:


If you use non-recursive autotools (and you should) then you won’t need to repeat that much.
I also added the option to DISTCHECK_CONFIGURE_FLAGS so I am forced to fix any warnings during make distcheck, when doing a tarball release. You don’t need to do that.

Whenever I build one of these projects from git I specify –enable-warnings=fatal to and fix any problems that it finds. That’s why there are zero compiler warnings or use of deprecated API in Glom.


You might prefer to copy the standalone version into your project instead. There are copies of the standalone macro in various projects already. Here is an example commit that adds it to a project.

The macro call looks like this in your, for instance:

  [-Wall -w1],
  [-pedantic -Wall -Wextra -w1],
Exit mobile version