[Gllug] Re: invalid type argument of `unary *'
John Winters
john at sinodun.org.uk
Sun Feb 19 18:18:54 UTC 2006
On Sun, 2006-02-19 at 18:02 +0000, Ian B wrote:
> On Sat, 2006-02-18 at 23:24 +0000, Adrian McMenamin wrote:
> > I know this question makes me look a hopeless C programmer, but there
> > you go.
> >
> > Why won't this compile? (I want to know what is in the address
> > 0xa0811000)
> >
> > long uBuf = 0xa0811000;
> > snd_printk("Buffer starts with %X\n", *uBuf);
>
> This works for me:
> long *uBuf = (long *) 0xa0811000;
> printf("Buffer at %X starts with %X\n",uBuf,*uBuf);
If your compiler accepts that without diagnostics then it's time to get
a better compiler or stop suppressing the warnings.
john at emperor:~/test$ cat printf.c
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
long *uBuf = (long *) 0xa0811000;
printf("Buffer at %X starts with %X\n",uBuf,*uBuf);
return 0;
}
john at emperor:~/test$ gcc -ansi -pedantic -Wall printf.c
printf.c: In function `main':
printf.c:7: warning: unsigned int format, pointer arg (arg 2)
printf.c:7: warning: unsigned int format, long int arg (arg 3)
john at emperor:~/test$
John
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list