Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2001:
[Freeciv-Dev] Re: Compiler-warnings
Home

[Freeciv-Dev] Re: Compiler-warnings

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv development list <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: Compiler-warnings
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 24 Jan 2001 21:46:34 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxxxx

On Wed, Jan 24, 2001 at 09:15:20PM +0100, Gerhard Killesreiter wrote:
> Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx> writes:
> 
> > Would it solve the problem if the type would be changed to unsigned
> > char or signed char? What are the advantages or disadvantages with
> > this approach compared to conversion to int?
> 
> I do not know. If you want me to try some patches or give me some code
> sample what to change, I'll try it. Sorry, my knowledge of C is zero.
> Try talking FORTRAN to me 8-)

For
-----------
int main()
{
  signed char s = 2;
  unsigned char u = 3;
  char c = 4;
  int arr[100];

  arr[s] = 5;
  arr[u] = 5;
  arr[c] = 5;

  return 0;
}
-----------
gcc -Wall gives:
a.c: In function `main':
a.c:10: warning: array subscript has type `char'

So it looks like gcc will accept signed or unsigned char as array
subscripts. It can also be done using int. Both solution will silence
the warning but maybe there is also something else to consider.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "Just because you put a flag on the moon doesn't make it yours, it just
  puts a hole in the moon."



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