Altera_Forum
Honored Contributor
11 years agoalt_types.h printf warning
Hi,
I am writing some C for a NIOS. I am using the data formats defined in alt_types.h, alt_u32 alt_u16 alt_u8. When I use printf with alt_u32 I am getting a warning: warning: format '%x' expects argument of type 'unsigned int', but argument <number> has type 'alt_u32' The printf still works and returns what I am expecting through the stdout. code example:
void main(void) {
alt_u8 test1;
test1 = 0x04;
printf("test1: %02x\n",test1);
alt_u32 test2;
test2 = 0x01020304;
printf("test2: %08x\n",test2);
return;
}
when compiled gives the above warning for both printf statements (note both errors state argument has type alt_u32 even though one is alt_u8) When I run this on my board the output is: test1: 04 test2: 01020304 My questions are: 1) Can I ignore this warning? I am assuming I can as it still works functionally 2) Can I get rid of it as I dont want every printf I use giving a warning when compiling. 3) Should I be using alt_types and alt_uX at all? should I use a more standard format? I am using them as they are in the software handbook and it seemed like the right idea. Thanks James