﻿# Can I use 32\-bit pointers in a 64\-bit application?

At present, the Microsoft Visual C\+\+ and GCC compilers do not allow you to use 32\-bit pointers in 64\-bit software created for processors based on x86\-64 architecture\. You can use 64\-bit registers and instruction sets together with 32\-bit pointers in 32\-bit programs on some other platforms \(for instance, PowerPC\)\.

The simplest way to circumvent the impossibility of using 32\-bit pointers is to store data in global arrays using 32\-bit types to index them\. The drawback of this method is the impossibility of dynamic memory allocation for such structures durring runtime\.

Another way is to encode 64\-bit pointers into 32 bits\. This [article](https://www.codeproject.com/articles/28818/32-bit-pointers-in-a-64-bit-world) thoroughly describes the operation principles of the 'sptr' function intended for data alignment and specifics and restrictions of its use\. The article contains samples illustrating mechanisms of encoding 64\-bit pointers into 32\-bit ones\.

## References

1. Discussion at www\.stackoverflow\.com\. [Can a C compiler generate an executable 64\-bits where pointers are 32\-bits?](https://stackoverflow.com/questions/4117005/can-a-c-compiler-generate-an-executable-64-bits-where-pointers-are-32-bits)
1. The Code Project\. [32\-bit pointers in a 64\-bit world](https://www.codeproject.com/articles/28818/32-bit-pointers-in-a-64-bit-world)
1. Knowledge Base\. [How to correctly cast a pointer to int in a 64\-bit application?](https://pvs-studio.com/en/blog/posts/cpp/k0005/)
1. Knowledge Base\. [What is the POINTER\_32 macro?](https://pvs-studio.com/en/blog/posts/k0043/)