How should I handle "cast from ‘void*’ to ‘int’ loses precision" when compiling 32-bit code on 64-bit machine?

32bit-64bit, c++, linux, portability

Solution

The issue is that, in 32bits, an int (which is a 32bit integer) will hold a pointer value.

When you move to 64bit, you can no longer store a pointer in an int - it isn't large enough to hold a 64bit pointer. The intptr_t type is designed for this.

Problem

I have a package that compiles and works fine on a 32-bit machine. I am now trying to get it to compile on a 64-bit machine and find the following error- ``` error: cast from ‘void*’ to ‘int’ loses precision ``` Is there a compiler flag to suppress these errors? or do I have to manually edit these files to avoid these casts?

Original source