warning: pointer targets ....... differ in signedness

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Compiling some code I get the following error.

../Humidor.c:633: warning: pointer targets in passing argument 1 of 'serlcdPrintData' differ in signedness

that line contains;

serlcdPrintData("  ",2);

in serlcd.h the prototype is;

void serlcdPrintData(uint8_t* data, uint8_t nBytes);

and in serlcd.c it's defined as;

void serlcdPrintData(uint8_t* data, uint8_t nBytes)
{
	uint8_t i;

	// print data
	for(i=0; i

What am I doing wrong?

Edward

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Literal strings in C (like " ") are of type char, not "unsigned char" and not "signed char" but just "char"

(and this is NOT affected by -fsigned-char or -funsigned-char - those only affect variable defintions).

So you should change the prototype of serlcdPrintData so that the first parameter is "char * data" and not "uint8_t * data" (because it isn't)

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Cool, thanks. Time to change a bunch of stuff then ;']

Edward

Yup works perfectly now.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
So you should change the prototype of serlcdPrintData so that the first parameter is "char * data" and not "uint8_t * data" (because it isn't)

On the other hand, there may be other cases where serlcdPrintData() is called with a uint8_t pointer because that the most convenient type to use in that situation. If this is the case, pick one type for the paremeter to serlcdPrintData() and then use a cast in the other cases:

serlcdPrintData((uint8_t *)"  ",2);

Don Kinzer
ZBasic Microcontrollers
http://www.zbasic.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, the most frequent way I have seen now that I know what's going on seems to be char* so I'll leave it as that and let people cast to char* if needed. Who wants to have to cast a literal like you did above? ;']

Edward

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

futrtrubl wrote:
Who wants to have to cast a literal like you did above?
My point was that you should define your functions in such a way as to minimize the number of times that you have to use a cast. Applying a cast to a string constant is no more difficult or unpalatable than doing so with any other expression form.

Don Kinzer
ZBasic Microcontrollers
http://www.zbasic.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
My point was that you should define your functions in such a way as to minimize the number of times that you have to use a cast

But in this case serlcdPrintData will always be sending printable characters to the LCD, so char* is the only thing that makes sense here.

Regards,
Steve A.

The Board helps those that help themselves.