Skip to content

main: Add missing locale.h include

Timothy Gu requested to merge TimothyGu/fprintd:locale into master

The include is present in all other binaries in utils/.


This was originally part of !41 (merged), but @hadess mentioned that

It's already included via #include <glib/gi18n.h> so the include isn't missing.

It turns out that glib/gi18n.h itself does not contain the locale.h include. In fact, locale.h only appears in glibc's libintl.h (which is itself included by glib/gi18n.h), guarded by the __OPTIMIZE__ macro:

/* Optimized version of the function above.  */
#if defined __OPTIMIZE__ && !defined __cplusplus

/* ... */

/* We need LC_MESSAGES for `dgettext'.  */
# include <locale.h>

Since __OPTIMIZE__ is not set in every build configuration, we shouldn't depend on this behavior – when all that's needed to fix it is just a single #include.

Thanks a lot.

Merge request reports

Loading