Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2002:
[Freeciv-Dev] Re: New Patch
Home

[Freeciv-Dev] Re: New Patch

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: "freeciv-dev@xxxxxxxxxxx" <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: New Patch
From: "Alexander Mai" <st002279@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 06 Feb 2002 15:22:38 +0100 (CET)
Reply-to: "Alexander Mai" <st002279@xxxxxxxxxxxxxxxxxxxxxx>

On Wed, 6 Feb 2002 13:46:04 +0000 (GMT), Ben Webb wrote:

>On Wed, 6 Feb 2002, Alexander Mai wrote:
>
>> >> -  freelog(LOG_DEBUG, "sizeof(struct cma_result)=%d",
>> >> -   sizeof(struct cma_result));
>> >> +  freelog(LOG_DEBUG, "sizeof(struct cma_result)=%ld",
>> >> +   (long)sizeof(struct cma_result));
>> >
>> >Why do you cast to long?
>> 
>> Well, isn't there the reverse warning as well if printing
>> an int (i.e. no long) with a "%li" specifier?
>
>       Er, no. "%li" means "long int" (or just "long"). "%ld" also means 
>"long int". "%d" or "%i" means "int".

So what?
Here's output from some gcc 2.9x:

#include <stdio.h>

void foo(void){

  long l;
  int i;

  printf("%i %li", i, i);
  printf("%i %li", l, l);

}
[E:\leer]gcc -Wall -W -c c.c
c.c: In function `foo':
c.c:8: warning: long int format, int arg (arg 3)
c.c:9: warning: int format, long int arg (arg 2)

There are indeed both kinds of warnings and my cast
to (long) is to be well justified.


---
Alexander Mai
st002279@xxxxxxxxxxxxxxxxxxxxxx




[Prev in Thread] Current Thread [Next in Thread]