avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [avr-gcc-list] Casting


From: Ron
Subject: RE: [avr-gcc-list] Casting
Date: Fri, 31 Mar 2006 22:41:36 +1100

> On Mar 28, 2006, at 3:46 AM, Ron wrote:
> 
> > I am using a <long> as a parameter in which I pass various 
> entities, 
> > sort of like a mailbox. Mostly they are longs, sometimes 
> integers, and 
> > sometimes I need to pass a pointer. In the latter case a 
> cast to long 
> > does not wholly satisfy the compiler (3.4.5), due to the size
> > difference
> > on AVRs, thus giving the warning:
> >
> > "cast from pointer to integer of different size"
> >
> > It is only a warning and the program works fine. However I would
> > like to
> > see a clean compile and so have been trying to find a combination of
> > casts that would promote a pointer to a long, but to no avail. Does
> > anyone have a suggestion?
> 
> Have you tried casting first to an integer of the same size? i.e.  
> with 16-bit pointers and 32-bit longs, then this should work:
> 
> unsigned long fromPtr(void *p)
> {
>      return  (unsigned long)(unsigned short)p;
> }
> 
> -- 
> Ned Konz
> address@hidden

This worked fine. Looks like there is no way to do it with a single
cast. I'll try Bjoern's typedef tomorrow as this looks like the way to
define the parameter itself.

Ron






reply via email to

[Prev in Thread] Current Thread [Next in Thread]