[coldfire-gnu-discuss] Warning messages

David Brown david at westcontrol.com
Fri Jan 5 10:43:17 UTC 2007


Hi John,

(Please turn off the request for read receipts in your email program - 
they do not work, and just annoy people, especially on mailing lists.)

What you are getting wrong here is that there are three types of char - 
"unsigned char", "signed char", and "char" (also known as plain char). 
A string literal is always a pointer to plain char, so if you pass it to 
a function expecting a pointer to unsigned chars, the signedness 
differes.  This is the case regardless of whether the compiler is using 
signed or unsigned values for plain chars (it's a compiler switch - I 
don't know what the default is for m68k gcc).

The way to deal with this is to be more specific about your data.  If 
you are dealing with strings and characters, then use plain char, 
including in the function declaration.  If what you want is eight bit 
numbers, then use "signed char" or "unsigned char" as appropriate (or, 
much better, use typedef'ed types - either standard ones like uint8, or 
your own ones).

mvh.,

David



DMS Tech, John wrote:
> I am getting the following warning messages in my code:
> 
>  
> 
> “warning: pointer targets in passing argument 1 of 'OSGetINI' differ in 
> signedness”
> 
>  
> 
> These warnings occur when I have declared the function with ‘unsigned 
> char *someparametername’ and I want to pass a constant string in the 
> function call. Example:
> 
>  
> 
> void somefunction(unsigned char *someparametername);
> 
>  
> 
> ..
> 
> ..
> 
> ..
> 
>             Somefunction(“This constant string”);
> 
> ..
> 
> ..
> 
> ..
> 
>  
> 
> When I switch these warnings off with the compiler option 
> ‘-Wno-pointer-sign’ these warnings are suppressed, but my question is 
> now when a real problem occurs like this example:
> 
>  
> 
> void somefunction(unsigned char *someparametername);
> 
>  
> 
> signed char *somesignedvariable;
> 
>  
> 
>> 
>> 
> Somefunction(somesignedvariable);
> 
>> 
>> 
> Is this going to get the warning still or is this warning also suppressed?
> 
>  
> 
> If so is there another way to stop the warnings from the first example 
> and still detect the warnings from the second?
> 
>  
> 
> John.
> 
>  
> 
>  
> 




More information about the coldfire-gnu-discuss mailing list