2010/2/22 Alon Bar-Lev <[email protected]>:
> Something like:
> ((void*)0)+dw
>
> On Mon, Feb 22, 2010 at 1:30 AM, Jim Michaels <[email protected]> wrote:
>>
>>
>> it's 32-bit windows 9x code, but the target is 64-bit, so I have to disable 
>> the 9x code.
>> I found a workaround on the internet (great place to look for solutions):
>> #if !defined(_WIN64)
>> ...//win9x code
>> #endif
>>
>>
>> ________________________________
>> From: Ozkan Sezer <[email protected]>
>> To: Jim Michaels <[email protected]>
>> Cc: mingw64 <[email protected]>
>> Sent: Fri, February 19, 2010 1:28:02 AM
>> Subject: Re: [Mingw-w64-public] x64 can't cast ptr to DWORD
>>
>> On Fri, Feb 19, 2010 at 11:25 AM, Jim Michaels <[email protected]> wrote:
>> > after much difficulty trying to get subscribed to the list, here is my
>> > question.
>> >
>> > #define CAST(x) reinterpret_cast<DWORD>( x )
>> > or
>> > #define CAST(x) (DWORD)( x )
>> > ...
>> >     // All msdos data structures must be packed on a 1 byte boundary
>> >     #pragma pack (1)
>> >     struct {
>> >       DWORD StartingSector ;
>> >       WORD NumberOfSectors ;
>> >       DWORD pBuffer;
>> >     } ControlBlock;
>> >     #pragma pack ()
>> > ...
>> >       ControlBlock.pBuffer = CAST(buffer) ;
>> >
>> > "dgeomlib.cpp:178: error: cast from 'unsigned char*' to 'DWORD' loses
>> > precision"
>> >
>> > this only occurs on 64-bit target compiler.
>> > how can I circumvent?
>>
>> Use DWORD_PTR instead.
>>
>> > or, how can I use ifdefs to disable this windows 9x code only for x64 
>> > target
>> > (obviously the x64-output compiler must have some sort of #define?)?
>> >
>>
>> #ifdef _WIN64 ... #endif  should do?
>>
>> >
>> > Jim Michaels
>> > [email protected](main)
>> > JesusnJim.com (my site)
>>
>> --
>> Ozkan
>> I don't think it's going to fit in 32 bits.
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Download Intel® Parallel Studio Eval
>> Try the new software tools for yourself. Speed compiling, find bugs
>> proactively, and fine-tune applications for parallel performance.
>> See why Intel Parallel Studio got high marks during beta.
>> http://p.sf.net/sfu/intel-sw-dev
>> _______________________________________________
>> Mingw-w64-public mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
>>
>
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Mingw-w64-public mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
>

The most valid way to solve this is in terms of Win32 API the use of
DWORD_PTR instead of DWORD. This magic about pointer casting can be
dangerous as it is pretty likely that you loose precission. The MS x64
ABI (a description can be found on msdn, or a small excerpe on our
Wiki) defines that the type 'long' remains 32-bit. As the type DWORD
is defined as 'unsigned long', it has 32-bit scalar width, but a
pointer on a 64-bit system has obviously 64-bit width. So the type to
use for casting from/to pointer to/from integer scalar is a 'long
long' type.
In general for such castings issues the types 'intptr_t' and
'uintptr_t', or the platform types 'DWORD_PTR', 'UINT_PTR', 'INT_PTR',
... should be used.

Regards,
Kai

-- 
|  (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to