I have having following warning in gcc compilation in 32 bit architecture but not having any such wa

Posted by thetna on Stack Overflow See other posts from Stack Overflow or by thetna
Published on 2010-03-11T15:18:09Z Indexed on 2010/03/26 1:33 UTC
Read the original article Hit count: 505

Filed under:
|

symbol.c: In function 'symbol_FPrint':

symbol.c:1209: warning: format '%ld' expects type 'long int', but argument 3 has type 'SYMBOL'
symbol.c: In function 'symbol_FPrintOtter':
symbol.c:1236: warning: format '%ld' expects type 'long int', but argument 3 has type 'SYMBOL'
symbol.c:1239: warning: format '%ld' expects type 'long int', but argument 3 has type 'SYMBOL'
symbol.c:1243: warning: format '%ld' expects type 'long int', but argument 3 has type 'SYMBOL'
symbol.c:1266: warning: format '%ld' expects type 'long int', but argument 3 has type 'SYMBOL' 

In symbol.c

1198 #ifdef CHECK
1199     else {
1200       misc_StartErrorReport();
1201       misc_ErrorReport("\n In symbol_FPrint: Cannot print symbol.\n");
1202       misc_FinishErrorReport();
1203     }
1204 #endif
1205   }
1206   else if (symbol_SignatureExists())
1207     fputs(symbol_Name(Symbol), File);
1208   else
1209     fprintf(File, "%ld", Symbol);
1210 }

And SYMBOL is defined as:

typedef size_t SYMBOL

When i replaced '%ld' with '%zu' , i got the following warning:

symbol.c: In function 'symbol_FPrint':
symbol.c:1209: warning: ISO C90 does not support the 'z' printf length modifier

Note: From here it has been edited on 26th of march 2010 and and following problem has beeen added because of its similarity to the above mentioned problem.

I have following statement:

printf("\n\t %4d:%4d:%4d:%4d:%4d:%s:%d", Index, S->info, S->weight,
       Precedence[Index],S->props,S->name, S->length);

The warning I get while compiling in 64 bit architecture is :

format ‘%4d’ expects type ‘int’, but argument 5 has type ‘size_t’

here are the definitions of parameter:

  NAT    props;
  typedef  unsigned int     NAT;

How can i get rid of this so that i can compile without warning in 32 and 64 bit architecture?

What can be its solution?

© Stack Overflow or respective owner

Related posts about 32bit-64bit

Related posts about gcc-warning