J
Joakim Hove
Hello,
I have code which makses use of variables of type size_t. The code is
originally developed on a 32 bit machine, but now it is run on both a
32 bit and a 64 bit machine.
In the code have statements like this:
size_t buffer_size;
printf("Total buffer size: %ud bytes \n",buffer_size);
Now the format "%ud" works nicely on the 32 bit computer; it actually
works on the 64 bit computer as well, but the compiler spits out
warning message. On the 64 bit computer it would have prefered:
printf("Total buffer size: %uld bytes \n",buffer_size); /* Or udl? */
As I said it works, but I would really prefer the program to compile
without warnings, as it is now I get *many* warnings of the type
file.c:line: warning: unsigned int format, different type arg (arg 1).
And, on several occasion this has actually led me to miss more
important warnings.
Any tips appreciated.
Joakim
--
Joakim Hove
hove AT ift uib no /
Tlf: +47 (55 5)8 27 90 / Stabburveien 18
Fax: +47 (55 5)8 94 40 / N-5231 Paradis
http://www.ift.uib.no/~hove/ / 55 91 28 18 / 92 68 57 04
I have code which makses use of variables of type size_t. The code is
originally developed on a 32 bit machine, but now it is run on both a
32 bit and a 64 bit machine.
In the code have statements like this:
size_t buffer_size;
printf("Total buffer size: %ud bytes \n",buffer_size);
Now the format "%ud" works nicely on the 32 bit computer; it actually
works on the 64 bit computer as well, but the compiler spits out
warning message. On the 64 bit computer it would have prefered:
printf("Total buffer size: %uld bytes \n",buffer_size); /* Or udl? */
As I said it works, but I would really prefer the program to compile
without warnings, as it is now I get *many* warnings of the type
file.c:line: warning: unsigned int format, different type arg (arg 1).
And, on several occasion this has actually led me to miss more
important warnings.
Any tips appreciated.
Joakim
--
Joakim Hove
hove AT ift uib no /
Tlf: +47 (55 5)8 27 90 / Stabburveien 18
Fax: +47 (55 5)8 94 40 / N-5231 Paradis
http://www.ift.uib.no/~hove/ / 55 91 28 18 / 92 68 57 04