Hello,
Using gnuarm with the following code:
int is_any(unsigned char *str, char ch)
{
unsigned char myCh;
while((myCh=*str++))
{
if (ch == myCh)
return ch;
}
return 0;
}
const unsigned char string1[]={"abcdefgh"};
int test()
{
char ch = 'd';
if(is_any(string1, ch)==0)
{
printf("Not there!");
return 1;
}
return 0;
}
returns this as a warning:
test.c: In function `test':
test.c:32: warning: passing arg 1 of `is_any' discards qualifiers from
pointer target type
this is because you're passing a "const uchar *" as a "uchar *"
param. Changing either the function to is_any(const unsigned char
*,char) or removing const from the string declaration removes this
warning, but it's only a warning, it won't effect the execution.
-- Sean
At 16:51 2/10/2006, you wrote:
>I finally got my avr asm app converted to gnuarm c
>and it compiles.
>
>However, it does not like:
>int is_any(unsigned char *, char);
>
>const unsigned char string1[]={"abcdefgh"};
>
>...
> ch = 'd';
> if(is_any(string1, ch)==0)....;
>
>I had other const strings, and it gave me warnings as well.
>
>Do we have to use const to ensure that the strings as constant
>and put in flash rather than ram?
>
>Thanks,
>
>GlenMessage
Re: [lpc2000] gnuarm question
2006-02-10 by Sean
Attachments
- No local attachments were found for this message.