/Wp64 and casting pointers to DWORDs

Most of my coding has been on 32 bit Windows and there has been this subconscious assumption I’ve always made that I could safely cast any pointer to a DWORD. I gotta change that now I guess though it’s tough to stop assuming my subconscious assumptions cause they are – well, subconscious assumptions (bad joke – yeah I know, I know, but I am in that sorta mood).

Luckily, if you turn on the /Wp64 compiler option, you’ll get a C4311 compiler warning if you attempt to do that. If you only intend to run your 32-bit programs in a 64-bit OS that supports 32-bit compatibility mode this is okay I guess, but if you want to take your code and recompile it using a 64-bit compiler in the near future, then it’d be best to turn on this /Wp64 option for all your current projects.

Advertisements

4 thoughts on “/Wp64 and casting pointers to DWORDs

  1. Uhm, I might add that I am talking about the VC++ compiler (version 7.1+) here before some GCC-lover starts abusing me of giving him misleading information 🙂

  2. BTW, the correct cast is now (DWORD_PTR) 🙂
    I wish MS had named their 32/64-bit compatible types something else, because I forsee newbies thinking “DWORD_PTR” is a typedef for “DWORD*” 😦

  3. Seriously an AMD64 box is just what you need now. Get the new Windows x64 edition (RC2 is out) and you are all set to go! A decent machine is around ~1k.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s