#63 warnings due to mismatch in stdint.h and inttypes.h

open
nobody
devkitARM (22)
5
2014-08-19
2008-09-26
Charles Lindsay
No

With a freshly-downloaded devkitARM r23b:

test.c:

include <stdio.h>

include <stdint.h>

include <inttypes.h>

int main(void)
{
int32_t a = 123;
printf("%"PRId32, a);
return 0;
}

To compile:
$DEVKITARM/bin/arm-eabi-gcc -Wall test.c
test.c: In function 'main':
test.c:9: warning: format '%ld' expects type 'long int', but argument 2 has type 'int32_t'
test.c:9: warning: format '%ld' expects type 'long int', but argument 2 has type 'int32_t'

Under normal gcc (and as per the C99 spec), gcc -Wall test.c should produce no warnings.

The problem is that the type of int32_t is 'signed int', but the value of PRId32 is "ld", which would cause printf() to print a 'long int'. Either the type of int32_t or the value of PRId32 (and perhaps others in the same vein) should change to match each other.

It's not a huge problem, but the warnings aren't pretty.

Also, I'm not sure if this comes from upstream or not. Apologies if it's the standard GNU headers that are at fault.

Discussion