How to use _W64 and __w64 in VC ++?

There is such a thing as __ w64 in Visual C ++ 9. I came across it trying to port my native C ++ DLL to 64 bits. In particular, crtdefs.h has this nice snippet:

 #if !defined(_W64) #if !defined(__midl) && (defined(_X86_) || defined (_M_IX86)) && _MSC_VER >= 1300 #define _W64 __w64 #else #define _W64 #endif #endif 

which, if I understand correctly, implies that for 64-bit _W64 is defined as an empty string and has no effect, but for 32-bit it is defined as __w64 .

I tried to define _W64 as an empty string and __w64 in turn, and at least both when the project is compiled in a 64-bit configuration.

So both _W64 and __w64 look useless. How do I plan to use them and how to define _W64 in 64-bit projects?

+4
source share
2 answers

The answer is no. This is a compiler for use by a 32-bit compiler. The original idea was that Microsoft wanted to prepare programmers for the upcoming 32-> 64-bit transition. Therefore, the 32-bit compiler was able to mark certain typedef as __w64. Microsoft then used this feature to label typedefs that would change in Win64.

+2
source

__w64 used to indicate types having different sizes in 32-bit and 64-bit environments. Then the compiler could issue a warning when you assigned a possibly-64-bit type to a 32-bit type.

If you switch MSDN: __w64 to the latest version, you will see that the keyword is out of date. VC9 even generates a warning when trying to compile with the / Wp64 switch.

+9
source

All Articles