Question about GdkPixbuf functions with a _utf8 suffix

In that file:
there are a few functions with an additional _utf8 suffix when built for Windows: gdk_pixbuf_new_from_file_utf8, gdk_pixbuf_new_from_file_utf8, gdk_pixbuf_new_from_file_at_scale_utf8, gdk_pixbuf_savev_utf8

They are defined with a directive:

#ifdef G_OS_WIN32
/* In previous versions these _utf8 variants where exported and linked to
 * by default. Export them here for ABI (and gi API) compat.

GdkPixbuf *gdk_pixbuf_new_from_file_utf8 (const char *filename,
                                          GError    **error);

and there is also a variadic function:

#ifndef __GTK_DOC_IGNORE__
#ifdef G_OS_WIN32
/* DLL ABI stability hack. */
#define gdk_pixbuf_save gdk_pixbuf_save_utf8

gboolean gdk_pixbuf_save           (GdkPixbuf  *pixbuf, 
                                    const char *filename, 
                                    const char *type, 
                                    GError    **error,
                                    ...) G_GNUC_NULL_TERMINATED;

On Windows, are we obliged to use those *_utf8 functions ? Or are they still there only for compatibility with old stuff?

No: you should always use the regular, non-_utf8 API. The _utf8 API is there for ABI compatibility reasons.

Internally, gdk-pixbuf will call the correct implementation depending on the platform; those symbols should not have been made public in the first place, but it’s a 20+ years old issue that cannot really be fixed without breaking API—which is something that won’t ever happen, at this point.

1 Like

Thanks a lot @ebassi for this precise answer (as always) that will simplify my work on my binding.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.