size_t is declared as unsigned int on 32-bit and unsigned long on 64-bit. As a
result, following code will emit a warning on amd-64:
printf ("%u\n", sizeof (int));
test.c:5: warning: format ‘%u’ expects type ‘unsigned
int’, but argument 2 has type ‘long unsigned int’
but changing the format would then fail on ia-32:
printf ("%lu\n", sizeof (int));
test.c:5: warning: format ‘%lu’ expects type ‘long unsigned
int’, but argument 2 has type ‘unsigned int’
there seems to be no way to satisfy this other than a cast, which seems a bit
awkward. Is there any reason for size_t not being "unsigned long" consistently
on all platforms?
--
Summary: typeof (size_t) inconsistency
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jimsmite at rocketmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43991