You receive a C4311 compiler message when you cast a 64-bit pointer to a 32-bit variable (329343)
The information in this article applies to:
- Microsoft Visual C++ .NET (2003)
- Microsoft Visual C++ .NET (2002)
This article was previously published under Q329343 SYMPTOMSWhen you try to cast a 64-bit pointer variable to a 32-bit integer variable or to a 32-bit long variable, you may receive the following C4311 compiler message: warning C4311: 'type cast' : pointer truncation from 'type1' to 'type2'
Note type1 is the data type of the pointer variable, and type2 is the data type of the variable that you are casting from the pointer type.CAUSEThis behavior only occurs when you try to cast a 64-bit pointer variable to a
32-bit integer variable or to a 32-bit long variable. This message detects 64-bit
portability issues. In Microsoft Windows 32-bit operating systems, you can cast a pointer to
a 32-bit integer variable or to a 32-bit long variable. However, you cannot do this in Windows 64-bit operating systems. In Windows 64-bit operating systems, the pointer variable is a 64-bit
wide pointer variable. If you try to cast a 64-bit pointer to
32-bit variable, information loss may occur.REFERENCES For additional information, visit the following Microsoft Developer Network (MSDN) Web
sites:
Modification Type: | Minor | Last Reviewed: | 1/5/2006 |
---|
Keywords: | kbhowto kbCompiler kbDocs kbinfo KB329343 kbAudDeveloper |
---|
|