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: Alexander Mai <st002279@xxxxxxxxxxxxxxxxxxxxxx>
Cc: "freeciv-dev@xxxxxxxxxxx" <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: New Patch
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 6 Feb 2002 16:19:06 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Wed, Feb 06, 2002 at 03:22:38PM +0100, Alexander Mai wrote:
> 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".
> 
> There are indeed both kinds of warnings and my cast
> to (long) is to be well justified.

The original code works without warning as long as size_t isn't a
long. There are no information about this in the C spec. To avoid this
you can do a cast to int: "(int)sizeof(...)".

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
  "With a PC, I always felt limited by the software available.
   On Unix, I am limited by my knowledge."
    -- Peter J. Schoenster <pschon@xxxxxxxxxxxxxxxxx>


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