__w64
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

__w64

Microsoft Specific

type __w64 identifier

where:

type
One of the three types that might cause problems in code being ported from a 32-bit to a 64-bit compiler: int, long, or a pointer.
identifier
The identifier for the variable you are creating.

Remarks

The __w64 keyword lets you mark variables, such that when you compile with /Wp64 the compiler will report any warnings that would be reported if you were compiling with a 64-bit compiler.

Any typedef that has __w64 on it must be 32 bits on x86 and 64 bits on ia64.

The __w64 modifier should be specified on any typedefs that change size between 32 bit and 64 bit platforms. For any such type, __w64 should appear only on the 32-bit definition of the typedef. For example:

#ifdef  _WIN64
typedef unsigned __int64    size_t;
#else
typedef _W64 unsigned int   size_t;
#endif

__w64 is ignored if the compilation does not use /Wp64.

Example

// __w64.cpp
// compile with: /W3 /Wp64
typedef int Int_32;
#ifdef _WIN64
typedef __int64 Int_Native;
#else
typedef int __w64 Int_Native;
#endif

int main()
{
   Int_32 i0 = 5;
   Int_Native i1 = 10;
   i0 = i1;   // C4244 64-bit int assigned to 32-bit int

   // char __w64 c;  error, cannot use __w64 on char
}

END Microsoft Specific

See Also

C++ Keywords

Show:
© 2016 Microsoft