Problem
I am making use of the GLib 2.0 library, and declared a gunit64 variable. I wish to print its value to screen, but its not working properly.
Code
Consider the following code snippet as an example. I declare a guint64 variable, and try to print its value.
guint64 myValue = 24324823479324;
printf("My Value: %d\n", myValue);
Warning
I get this warning:
warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘guint64’
Output
I get a strange negative number on screen:
My Value: -1871285220
Further Comments
I tried to search the API's documentation, and I found the following under guint64:
An unsigned integer guaranteed to be 64 bits on all platforms. Values of this type can range from 0 to G_MAXUINT64 (= 18,446,744,073,709,551,615).
To print or scan values of this type, use G_GINT64_MODIFIER and/or G_GUINT64_FORMAT.
Therefore, I assume I have to use either the modifier or format definitions. However, the documentation does not show how to use them. Can anybody help me please?
printf("My value: %" G_GUINT64_FORMAT "\n", myValue);
instead. – Diez