public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Cast void * to u_int
@ 2010-02-04 18:28 Brian McGrew
  2010-02-04 18:37 ` Adel Abushaev
  0 siblings, 1 reply; 4+ messages in thread
From: Brian McGrew @ 2010-02-04 18:28 UTC (permalink / raw)
  To: gcc-help

Good morning!

I have a line of code as follows (excuse erroneous capitulation, it's my
mailer)

XtPointer client_data; // which is really void *
u_int days = reinterpret_cast<u_int>(client_data);

When I compile with gcc-4.1.2 I get:

error: cast from 'void*' to 'u_int' looses precision

This is the first time I've tried to rebuild this program with gcc-4, it was
previously build with gcc-2.95.2 (really old code but it works and is
simple).

What am I missing here???

Thanks!

-b

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Cast void * to u_int
  2010-02-04 18:28 Cast void * to u_int Brian McGrew
@ 2010-02-04 18:37 ` Adel Abushaev
  2010-02-04 18:56   ` Brian McGrew
  0 siblings, 1 reply; 4+ messages in thread
From: Adel Abushaev @ 2010-02-04 18:37 UTC (permalink / raw)
  To: Brian McGrew; +Cc: gcc-help

u_int is always 32bit.

A.

On Thu, Feb 4, 2010 at 10:26 AM, Brian McGrew <brian@visionpro.com> wrote:
> Good morning!
>
> I have a line of code as follows (excuse erroneous capitulation, it's my
> mailer)
>
> XtPointer client_data; // which is really void *
> u_int days = reinterpret_cast<u_int>(client_data);
>
> When I compile with gcc-4.1.2 I get:
>
> error: cast from 'void*' to 'u_int' looses precision
>
> This is the first time I've tried to rebuild this program with gcc-4, it was
> previously build with gcc-2.95.2 (really old code but it works and is
> simple).
>
> What am I missing here???
>
> Thanks!
>
> -b
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Cast void * to u_int
  2010-02-04 18:37 ` Adel Abushaev
@ 2010-02-04 18:56   ` Brian McGrew
  2010-02-08  0:25     ` Thomas Martitz
  0 siblings, 1 reply; 4+ messages in thread
From: Brian McGrew @ 2010-02-04 18:56 UTC (permalink / raw)
  To: Adel Abushaev; +Cc: gcc-help

DOH!  

I knew that.  Much better now!  (see what happens when you work all night
with no sleep!)

-b


On 2/4/10 10:28 AM, "Adel Abushaev" <adel.abushaev@gmail.com> wrote:

> u_int is always 32bit.
> 
> A.
> 
> On Thu, Feb 4, 2010 at 10:26 AM, Brian McGrew <brian@visionpro.com> wrote:
>> Good morning!
>> 
>> I have a line of code as follows (excuse erroneous capitulation, it's my
>> mailer)
>> 
>> XtPointer client_data; // which is really void *
>> u_int days = reinterpret_cast<u_int>(client_data);
>> 
>> When I compile with gcc-4.1.2 I get:
>> 
>> error: cast from 'void*' to 'u_int' looses precision
>> 
>> This is the first time I've tried to rebuild this program with gcc-4, it was
>> previously build with gcc-2.95.2 (really old code but it works and is
>> simple).
>> 
>> What am I missing here???
>> 
>> Thanks!
>> 
>> -b
>> 
>> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Cast void * to u_int
  2010-02-04 18:56   ` Brian McGrew
@ 2010-02-08  0:25     ` Thomas Martitz
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Martitz @ 2010-02-08  0:25 UTC (permalink / raw)
  To: gcc-help

On 04.02.2010 19:37, Brian McGrew wrote:
> DOH!
>
> I knew that.  Much better now!  (see what happens when you work all night
> with no sleep!)
>
> -b
>
>
> On 2/4/10 10:28 AM, "Adel Abushaev"<adel.abushaev@gmail.com>  wrote:
>
>    
>> u_int is always 32bit.
>>
>> A.
>>
>> On Thu, Feb 4, 2010 at 10:26 AM, Brian McGrew<brian@visionpro.com>  wrote:
>>      
>>> Good morning!
>>>
>>> I have a line of code as follows (excuse erroneous capitulation, it's my
>>> mailer)
>>>
>>> XtPointer client_data; // which is really void *
>>> u_int days = reinterpret_cast<u_int>(client_data);
>>>
>>> When I compile with gcc-4.1.2 I get:
>>>
>>> error: cast from 'void*' to 'u_int' looses precision
>>>
>>> This is the first time I've tried to rebuild this program with gcc-4, it was
>>> previously build with gcc-2.95.2 (really old code but it works and is
>>> simple).
>>>
>>> What am I missing here???
>>>
>>> Thanks!
>>>
>>> -b
>>>
>>>
>>>        
>    

Pointer-to-int conversion should always happen with intptr_t.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-02-07 14:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-04 18:28 Cast void * to u_int Brian McGrew
2010-02-04 18:37 ` Adel Abushaev
2010-02-04 18:56   ` Brian McGrew
2010-02-08  0:25     ` Thomas Martitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).