Linux 64 bit int to pointer cast warnings


#1

There are some int to pointer cast warnings on Linux 64 bit for quite a long time.

In file included from ../../../../modules/juce_core/juce_core.cpp:163:0:
../../../../modules/juce_core/native/juce_posix_SharedCode.h: In member function ‘void juce::FileInputStream::openHandle()’:
../../../../modules/juce_core/native/juce_posix_SharedCode.h:423:30: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
../../../../modules/juce_core/native/juce_posix_SharedCode.h: In member function ‘void juce::FileOutputStream::openHandle()’:
../../../../modules/juce_core/native/juce_posix_SharedCode.h:468:38: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
../../../../modules/juce_core/native/juce_posix_SharedCode.h:486:34: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]

This fixes the warnings here

diff --git a/modules/juce_core/native/juce_posix_SharedCode.h b/modules/juce_core/native/juce_posix_SharedCode.h
index 417fee8..69a8f99 100644
--- a/modules/juce_core/native/juce_posix_SharedCode.h
+++ b/modules/juce_core/native/juce_posix_SharedCode.h
@@ -420,7 +420,7 @@ void FileInputStream::openHandle()
     const int f = open (file.getFullPathName().toUTF8(), O_RDONLY, 00644);
 
     if (f != -1)
-        fileHandle = (void*) f;
+        fileHandle = (void*) ((intptr_t) f);
     else
         status = getResultForErrno();
 }
@@ -465,7 +465,7 @@ void FileOutputStream::openHandle()
 
             if (currentPosition >= 0)
             {
-                fileHandle = (void*) f;
+                fileHandle = (void*) ((intptr_t) f);
             }
             else
             {
@@ -483,7 +483,7 @@ void FileOutputStream::openHandle()
         const int f = open (file.getFullPathName().toUTF8(), O_RDWR + O_CREAT, 00644);
 
         if (f != -1)
-            fileHandle = (void*) f;
+            fileHandle = (void*) ((intptr_t) f);
         else
             status = getResultForErrno();
     }

Could this be the fix? Would be nice if JUCE builds without warnings.

Peter


#2

Yes, sorry! I had no idea those warnings were getting triggered. I’ll tidy up…