Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Casting ctype lookups

I am getting warnings (errors with -Werror) when I do things like this:

#include <stdio.h>
void func(char *s)
  while (*s) *s = toupper(*s);
int main(void)
  printf("%s\n", func("Test string");
  return 0;

$ gcc -o t -Wall -Werror t.c
cc1: warnings being treated as errors
t.c: In function 'func':
t.c:6:3: error: array subscript has type 'char'

Should the inline macro cast the args for these table lookups?  I would
like to modify sys/ctype_inline.h to change lookup lines like;

#define toupper(c)  ((int)((_toupper_tab_ + 1)[(c)]))     
#define toupper(c)  ((int)((_toupper_tab_ + 1)[(int)(c)]))

or else add a comment why they should not be cast.  Which should it be?

D'Arcy J.M. Cain <> IM:darcy%Vex.Net@localhost

Home | Main Index | Thread Index | Old Index