Incorrect g_print() specifiers on 64-bit system
While trying to create cross-build system on a 64-bit Linux system I built Pango-1.43.0 and ran into some warnings:
[91/164] Compiling C object 'pango/82b5c0c@@pango-1.0@sha/pango-emoji.c.obj'.
emoji_presentation_scanner.rl: In function ‘scan_emoji_presentation’:
../pango/pango-emoji.c:198:21: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘long long int’ [-Wformat=]
if (0) g_print ("emoji %ld..%ld\n", ts - buffer, te - buffer); \
^
emoji_presentation_scanner.rl:71:11: note: in expansion of macro ‘found_emoji_presentation_sequence’
../pango/pango-emoji.c:198:21: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘long long int’ [-Wformat=]
if (0) g_print ("emoji %ld..%ld\n", ts - buffer, te - buffer); \
^
emoji_presentation_scanner.rl:71:11: note: in expansion of macro ‘found_emoji_presentation_sequence’
../pango/pango-emoji.c:198:21: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘long long int’ [-Wformat=]
if (0) g_print ("emoji %ld..%ld\n", ts - buffer, te - buffer); \
^
emoji_presentation_scanner.rl:71:11: note: in expansion of macro ‘found_emoji_presentation_sequence’
../pango/pango-emoji.c:198:21: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘long long int’ [-Wformat=]
if (0) g_print ("emoji %ld..%ld\n", ts - buffer, te - buffer); \
^
emoji_presentation_scanner.rl:71:11: note: in expansion of macro ‘found_emoji_presentation_sequence’
../pango/pango-emoji.c:198:21: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘long long int’ [-Wformat=]
if (0) g_print ("emoji %ld..%ld\n", ts - buffer, te - buffer); \
^
emoji_presentation_scanner.rl:71:13: note: in expansion of macro ‘found_emoji_presentation_sequence’
../pango/pango-emoji.c:198:21: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘long long int’ [-Wformat=]
if (0) g_print ("emoji %ld..%ld\n", ts - buffer, te - buffer);
Obviously, for a long long int
the format specifier should be %lld, not %ld.
I cross-compiled a simple file on my VM:
#include <glib.h>
#include <windows.h>
int WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCommandLine,
int nShowCommand)
{
long long int x = 42;
g_print("WinMain called\n");
g_print("The answer is %lld\n", x);
return 0;
}
That compiles and runs fine, if I change %lld to %ld, gcc complains, as it should.
So it's not a bug in my cross-build system, but probably a bug in Pango.