Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

char - signed or unsigned

2005-05-28 by Matthew Kavalauskas

I am using arm-elf-gcc and get a compiler warning for the following
code:

 

typedef unsigned char uint8_t;
void main (void)

{

  uint8_t txBuf[25];

  strcpy(txBuf, "number");

}

 

above code produces:

warning: pointer targets in passing argument 1 of 'strcpy' differ in
signedness

 

"number" seems to be created as signed char.  My understanding is that
char is (in general) undefined whether it is signed or unsigned.
Specific compilers choose one or the other, but code should not assume
one or the other if the goal is portability.  I found some information
stating that arm-elf-gcc defines char as unsigned, so I shouldn't get
the warning in the first place.  Additionally, the flag -funsigned-char
for arm-elf-gcc should force it to be unsigned, but adding the flag
still produces the warning.  Can anyone suggest how to get rid of it?  I
would strongly prefer my char to be unsigned.

 

Thanks for the help.

Matt

 



[Non-text portions of this message have been removed]

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.