[Freeciv-Dev] Re: New Patch
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Wed, 6 Feb 2002, Alexander Mai wrote:
> On Wed, 6 Feb 2002 16:19:06 +0100, Raimar Falke wrote:
> >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(...)".
>
> In turn your proposal would break if sizeof() is actually
> of type long.
I think "break" is a harsh word for it. Bad things would only
happen if you can't cast to int. If you're really using structures for
which sizeof() returns a value that doesn't fit into 32 bits, perhaps you
should consider using smaller structures!
> My solution is perhaps not perfect, just "better" and for most
> systems it is fine. Printing size_t is a famous programming FAQ.
Well, if you want to get picky about it, you should be casting it
to unsigned long, given that sizeof() always returns a positive value.
Alternatively, you could use the "%zd" format specifier on systems that
support this.
> You don't need to teach me C programming, guys.
Hey, I wasn't complaining about that. My only point was that your
statement (and I quote verbatim) 'printing an int (i.e. no long) with a
"%li" specifier' was incorrect - %li prints a long int, not an int.
Ben
--
ben@xxxxxxxxxxxxxxxxxxxxxx http://bellatrix.pcl.ox.ac.uk/~ben/
"I need a big loan from the girl zone"
- [Freeciv-Dev] Re: New Patch, (continued)
- [Freeciv-Dev] Re: New Patch, Alexander Mai, 2002/02/06
- [Freeciv-Dev] Re: New Patch, Raimar Falke, 2002/02/06
- [Freeciv-Dev] Re: New Patch, Alexander Mai, 2002/02/06
- [Freeciv-Dev] Re: New Patch, Raimar Falke, 2002/02/06
- [Freeciv-Dev] Re: New Patch, Alexander Mai, 2002/02/06
- [Freeciv-Dev] Re: New Patch, Raimar Falke, 2002/02/06
- [Freeciv-Dev] Re: New Patch, Tony Stuckey, 2002/02/06
- [Freeciv-Dev] Re: New Patch, Alexander Mai, 2002/02/06
- [Freeciv-Dev] Re: New Patch, Vasco Alexandre Da Silva Costa, 2002/02/06
- [Freeciv-Dev] Re: New Patch, Alexander Mai, 2002/02/07
- [Freeciv-Dev] Re: New Patch,
Ben Webb <=
|
|