wirrbel
wirrbel

Reputation: 3299

C11/C17: Explicit casting char* to uint8_t* leads to a -Wpointer-sign warning

So I get this warning

warning: passing 'char[6]' to parameter of type 'uint8_t *' (aka 'unsigned char *') converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Wpointer-sign]

from compiling the following code which calls a void my_func(uint8_t *) function:

my_func(UINT8_C("world"));

UINT8_C is from stdlib.h

IIRC the same thing happened when using

my_func((uint8_t)("world"));

I would have expected that the explicit cast does away with the warning, why not?

Upvotes: 1

Views: 120

Answers (1)

pts
pts

Reputation: 87291

Depending on the compiler and the settings, char may be signed or unsigned. You may want to use clang -funsigned-char.

Upvotes: -2

Related Questions