Unsigned Char

Hi again;
I have a function defined as:
void button_build_hor(long px,long py,long width,long high,long c_bt,unsigned char *tx,char num_tx,long c_tx)

Which is a canned program from NXP for an LCD screen driver.

My calls to the function (and there are a gazillion of them) look like this:

button_build_hor(250,205,50,30,BT_BLUE,"1",1,WHITE);

I am getting a warning on each function call for a signdness difference. The error is listed below:

../src/LCD_Driver.c:195:3: warning: pointer targets in passing argument 6 of 'button_build_hor' differ in signedness
../src/LCD_Driver.c:167:6: note: expected 'unsigned char *' but argument is of type 'char *'

How do I correct this as the number of warnings are overwelming.
closed account (zb0S216C)
It's a type mismatch warning. It's telling you that char* and unsigned char* are two different types and there could be a possible loss of data when passing between them. Usually, integral types are unsigned by default, but this may not be the case for you. What you'll have to do is change the type-specifier of the object you're passing to unsigned char*, or you could cast the type to unsigned char*, but I would only resort to that if I was desperate.

What compiler are you using (not the IDE)?

Wazzak
Last edited on
Hi and thanks soooooo much

I am using LPCXpress and this code ends up on a NXP microcontroller. The compiler is eclipse which comes with their system.

So I am clear, the warning is on the

"1"

and the pointer

"unsigned char *tx"

and the compiler is saying that the "1" is a signed variable and it is not happy that I am assigning that to and unsigned variable - is this correct?

I also went and found where tx is declared and it is type char (not unsigned) - could this also be a problem?

So if I understand, you are suggesting I need to change the "1" type specifier???
closed account (zb0S216C)
SrWalterR wrote:
So if I understand, you are suggesting I need to change the "1" type specifier??? (sic)

You cannot change the type-specifier of a literal, nor can you change the value of one.

SrWalterR wrote:
So I am clear, the warning is on the

"1" (sic)

Add the U suffix to the 1. This will denote the literal as unsigned. However, judging by the use of integers and pointers, are you trying to access addresses within a memory region?

Wazzak
Topic archived. No new replies allowed.