Menu

#36 Bad printf modifiers for 'size_t' arguments

open
nobody
None
5
2012-12-09
2008-02-26
No

When using 'size_t' arguments, you have to use modifiers like '%zu'. A plain '%u' will generate warnings like

--
#include <stdio.h>
int main()
{
size_t a=1;
printf("%u\n", a);
}
--

LANG=C gcc -Wall /tmp/foo.c
/tmp/foo.c: In function 'main':
/tmp/foo.c:5: warning: format '%u' expects type 'unsigned int', but argument 2 has type 'size_t'

Attached patch fixes these issues

Discussion

  • Enrico Scholz

    Enrico Scholz - 2010-01-14

    patch against 1.21.00

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.