I don't understand why the last two lines cause warning using strlen(). Shouldn't the compiler ignore these?
char cstr = "char string";
signed char scstr = "signed char string";
unsigned char ucstr = "unsigned char string";
len = strlen(cstr);
len = strlen(scstr); /* warns when char is unsigned */
len = strlen(ucstr); /* warns when char is signed */
Because the prototype is:
size_t strlen ( const char * str );
as stated on the ref.
An implicit conversion is happening in these lines, thus the warnings. Read more here: How can I avoid gcc warning for plain "char" to : "unsigned char" OR "signed char" conversion?
As Pete Becker stated:
unsigned char involves an implicit conversion.
unsigned char* to
char*, as in the code in the question, is not valid, and requires a diagnostic. "