GNOME Bugzilla – Bug 769139
g_log_writer_journald uses non-standard 'htole64' function
Last modified: 2016-07-25 16:33:22 UTC
g_log_writer_journald is no longer guarded by HAVE_LIBSYSTEMD, so the code inside the function will be compiled on all platforms. However, it uses non-standard 'htole64' function, which is not available in POSIX.
gmessages.c:1933:18: error: implicit declaration of function 'htole64' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
nstr = htole64 (length);
1 error generated.
FreeBSD requires sys/endian.h to be included before using htole64, but I think we should not add #include to fix the problem because the code is never used on non-Linux systems.
Simply including endian.h doesn't work. glibc uses endian.h, but other systems may use sys/endian.h.
glib/gmessages.c:109:10: fatal error: 'endian.h' file not found
As 'htole64' is non-standard, isn't it required to check it before using?
If the function needs to be compiled on non-Linux, this sounds like a job for GINT64_TO_LE().
Or possibly GUINT64_TO_LE, depending on signedness.