This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Avoiding "assignment from incompatible pointer type" warning


Ah, OK.  When I tried casting earlier, I was putting the cast on the lvalue.
I don't have the world's sharpest tech mind but with persistence I'll get it
eventually.

> -----Original Message-----
> From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org]On
> Behalf Of Joshua Nye
> Sent: Sunday, October 13, 2002 12:28 PM
> To: Steve Dondley; gcc-help@gcc.gnu.org
> Subject: Re: Avoiding "assignment from incompatible pointer type"
> warning
>
>
> Hi Steve,
>
> What you're looking for is a cast. i.e.:
>
> int *p;
> float g = 3.141592653589793238;
> p = (int *)&g;
>
> --josh
>
> ----- Original Message -----
> From: "Steve Dondley" <s@dondley.com>
> To: <gcc-help@gcc.gnu.org>
> Sent: Sunday, October 13, 2002 12:13 PM
> Subject: Avoiding "assignment from incompatible pointer type" warning
>
>
> > Hi,
> >
> > I've written a simple program that print out each bit of a
> floating point
> > variable so I can learn how floating point numbers are represented in
> > memory.  The program contains the following statements:
> >
> > int *p;
> > float g = 2.0625;
> > p = &g;
> >
> > The third statement above generates an "assignment from incompatible
> pointer
> > type" warning for obvious reasons.  Other than this, the
> program compiles
> > fine and works.
> >
> > My question is:  Is there a way to properly assign a pointer of one type
> to
> > a variable of different type so that the warning is suppressed?
> >
> > Thanks again.
> >
> >
>
>
>



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]