From 6b1654e1d248df32547e2e6cacba73f82aeb0a2a Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 24 Sep 2012 15:45:25 +0100 Subject: [PATCH] Fixed some more warnings. --- .../Introjucer/JuceLibraryCode/BinaryData.cpp | 2 +- .../Source/Utility/jucer_CodeHelpers.cpp | 4 ++-- .../JuceDemo/JuceLibraryCode/BinaryData.cpp | 2 +- .../Source/demos/AudioDemoLatencyPage.cpp | 2 +- .../Source/demos/AudioDemoTabComponent.cpp | 2 +- .../Source/demos/InterprocessCommsDemo.cpp | 2 +- .../the jucer/JuceLibraryCode/BinaryData.cpp | 2 +- .../native/juce_mac_CoreMidi.cpp | 2 +- .../codecs/juce_OggVorbisAudioFormat.cpp | 18 +++++++-------- .../format/juce_AudioFormatReader.cpp | 6 ++--- .../juce_core/containers/juce_OwnedArray.h | 2 +- modules/juce_core/memory/juce_Memory.h | 4 ++-- modules/juce_core/native/juce_mac_Files.mm | 2 +- modules/juce_core/native/juce_mac_Network.mm | 4 ++-- modules/juce_core/native/juce_mac_Strings.mm | 6 ++--- .../juce_core/native/juce_mac_SystemStats.mm | 14 ++++++------ .../juce_core/native/juce_posix_NamedPipe.cpp | 6 ++--- .../juce_core/native/juce_posix_SharedCode.h | 6 ++--- modules/juce_core/network/juce_Socket.cpp | 8 +++---- .../streams/juce_MemoryInputStream.cpp | 2 +- .../streams/juce_MemoryOutputStream.cpp | 9 ++++---- .../text/juce_CharacterFunctions.cpp | 2 +- .../juce_core/text/juce_CharacterFunctions.h | 2 +- modules/juce_core/text/juce_String.cpp | 18 +++++++-------- modules/juce_core/text/juce_StringArray.cpp | 2 +- modules/juce_core/text/juce_TextDiff.cpp | 6 ++--- .../juce_core/threads/juce_ChildProcess.cpp | 2 +- modules/juce_core/threads/juce_Thread.cpp | 2 +- modules/juce_core/threads/juce_ThreadPool.cpp | 4 ++-- .../zip/juce_GZIPCompressorOutputStream.cpp | 13 ++++++----- .../zip/juce_GZIPDecompressorInputStream.cpp | 4 ++-- modules/juce_graphics/fonts/juce_Font.cpp | 2 +- .../image_formats/juce_JPEGLoader.cpp | 2 +- .../image_formats/juce_PNGLoader.cpp | 9 ++++++++ modules/juce_graphics/images/juce_Image.cpp | 2 +- .../juce_graphics/images/juce_ImageCache.cpp | 5 +++-- .../juce_graphics/native/juce_mac_Fonts.mm | 12 +++++----- .../lookandfeel/juce_LookAndFeel.cpp | 2 +- .../native/juce_mac_MainMenu.mm | 2 +- .../native/juce_mac_NSViewComponentPeer.mm | 5 +++-- .../windows/juce_TooltipWindow.cpp | 2 +- .../juce_CPlusPlusCodeTokeniser.cpp | 2 +- .../misc/juce_BubbleMessageComponent.cpp | 2 +- modules/juce_opengl/native/juce_OpenGL_osx.h | 22 +++++++++---------- .../opengl/juce_OpenGLFrameBuffer.cpp | 2 +- .../opengl/juce_OpenGLShaderProgram.cpp | 12 +++++----- .../juce_opengl/opengl/juce_OpenGLTexture.cpp | 2 +- 47 files changed, 129 insertions(+), 116 deletions(-) diff --git a/extras/Introjucer/JuceLibraryCode/BinaryData.cpp b/extras/Introjucer/JuceLibraryCode/BinaryData.cpp index a871db7b88..e92d175718 100644 --- a/extras/Introjucer/JuceLibraryCode/BinaryData.cpp +++ b/extras/Introjucer/JuceLibraryCode/BinaryData.cpp @@ -880,7 +880,7 @@ const char* getNamedResource (const char* resourceNameUTF8, int& numBytes) throw unsigned int hash = 0; if (resourceNameUTF8 != 0) while (*resourceNameUTF8 != 0) - hash = 31 * hash + *resourceNameUTF8++; + hash = 31 * hash + (unsigned int) *resourceNameUTF8++; switch (hash) { diff --git a/extras/Introjucer/Source/Utility/jucer_CodeHelpers.cpp b/extras/Introjucer/Source/Utility/jucer_CodeHelpers.cpp index a573dab5e2..72ee6a777d 100644 --- a/extras/Introjucer/Source/Utility/jucer_CodeHelpers.cpp +++ b/extras/Introjucer/Source/Utility/jucer_CodeHelpers.cpp @@ -343,7 +343,7 @@ namespace CodeHelpers const char* t = s.toUTF8(); unsigned int hash = 0; while (*t != 0) - hash = hashMultiplier * hash + *t++; + hash = hashMultiplier * hash + (unsigned int) *t++; return hash; } @@ -387,7 +387,7 @@ namespace CodeHelpers out << indent << "unsigned int hash = 0;" << newLine << indent << "if (" << utf8PointerVariable << " != 0)" << newLine << indent << " while (*" << utf8PointerVariable << " != 0)" << newLine - << indent << " hash = " << hashMultiplier << " * hash + *" << utf8PointerVariable << "++;" << newLine + << indent << " hash = " << hashMultiplier << " * hash + (unsigned int) *" << utf8PointerVariable << "++;" << newLine << newLine << indent << "switch (hash)" << newLine << indent << "{" << newLine; diff --git a/extras/JuceDemo/JuceLibraryCode/BinaryData.cpp b/extras/JuceDemo/JuceLibraryCode/BinaryData.cpp index be9e534564..4139f791ae 100644 --- a/extras/JuceDemo/JuceLibraryCode/BinaryData.cpp +++ b/extras/JuceDemo/JuceLibraryCode/BinaryData.cpp @@ -2147,7 +2147,7 @@ const char* getNamedResource (const char* resourceNameUTF8, int& numBytes) throw unsigned int hash = 0; if (resourceNameUTF8 != 0) while (*resourceNameUTF8 != 0) - hash = 31 * hash + *resourceNameUTF8++; + hash = 31 * hash + (unsigned int) *resourceNameUTF8++; switch (hash) { diff --git a/extras/JuceDemo/Source/demos/AudioDemoLatencyPage.cpp b/extras/JuceDemo/Source/demos/AudioDemoLatencyPage.cpp index 36c9857cc3..13287eb5f1 100644 --- a/extras/JuceDemo/Source/demos/AudioDemoLatencyPage.cpp +++ b/extras/JuceDemo/Source/demos/AudioDemoLatencyPage.cpp @@ -152,7 +152,7 @@ public: // We need to clear the output buffers, in case they're full of junk.. for (int i = 0; i < numOutputChannels; ++i) if (outputChannelData[i] != 0) - zeromem (outputChannelData[i], sizeof (float) * numSamples); + zeromem (outputChannelData[i], sizeof (float) * (size_t) numSamples); } } diff --git a/extras/JuceDemo/Source/demos/AudioDemoTabComponent.cpp b/extras/JuceDemo/Source/demos/AudioDemoTabComponent.cpp index 7452f55c06..fc20f37af8 100644 --- a/extras/JuceDemo/Source/demos/AudioDemoTabComponent.cpp +++ b/extras/JuceDemo/Source/demos/AudioDemoTabComponent.cpp @@ -105,7 +105,7 @@ void LiveAudioInputDisplayComp::audioDeviceIOCallback (const float** inputChanne // We need to clear the output buffers, in case they're full of junk.. for (int i = 0; i < numOutputChannels; ++i) if (outputChannelData[i] != 0) - zeromem (outputChannelData[i], sizeof (float) * numSamples); + zeromem (outputChannelData[i], sizeof (float) * (size_t) numSamples); } //[/MiscUserDefs] diff --git a/extras/JuceDemo/Source/demos/InterprocessCommsDemo.cpp b/extras/JuceDemo/Source/demos/InterprocessCommsDemo.cpp index 2c5033fe6d..b5f8f6af88 100644 --- a/extras/JuceDemo/Source/demos/InterprocessCommsDemo.cpp +++ b/extras/JuceDemo/Source/demos/InterprocessCommsDemo.cpp @@ -112,7 +112,7 @@ public: // The send button has been pressed, so write out the contents of the // text box to the socket or pipe, depending on which is active. const String text (sendText.getText()); - MemoryBlock messageData (text.toUTF8(), text.getNumBytesAsUTF8()); + MemoryBlock messageData (text.toUTF8(), (size_t) text.getNumBytesAsUTF8()); for (int i = activeConnections.size(); --i >= 0;) { diff --git a/extras/the jucer/JuceLibraryCode/BinaryData.cpp b/extras/the jucer/JuceLibraryCode/BinaryData.cpp index a65527654b..4a6437a147 100644 --- a/extras/the jucer/JuceLibraryCode/BinaryData.cpp +++ b/extras/the jucer/JuceLibraryCode/BinaryData.cpp @@ -514,7 +514,7 @@ const char* getNamedResource (const char* resourceNameUTF8, int& numBytes) throw unsigned int hash = 0; if (resourceNameUTF8 != 0) while (*resourceNameUTF8 != 0) - hash = 31 * hash + *resourceNameUTF8++; + hash = 31 * hash + (unsigned int) *resourceNameUTF8++; switch (hash) { diff --git a/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp b/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp index f3593aa007..e88dfd8c58 100644 --- a/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp +++ b/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp @@ -370,7 +370,7 @@ void MidiOutput::sendMessageNow (const MidiMessage& message) const int maxPacketSize = 256; int pos = 0, bytesLeft = (int) dataSize; const int numPackets = (bytesLeft + maxPacketSize - 1) / maxPacketSize; - allocatedPackets.malloc ((size_t) (32 * numPackets + dataSize), 1); + allocatedPackets.malloc ((size_t) (32 * (size_t) numPackets + dataSize), 1); packetToSend = allocatedPackets; packetToSend->numPackets = (UInt32) numPackets; diff --git a/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp index f89e3ace49..07427e361e 100644 --- a/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp @@ -37,11 +37,11 @@ namespace OggVorbisNamespace #pragma warning (disable: 4267 4127 4244 4996 4100 4701 4702 4013 4133 4206 4305 4189 4706 4995 4365) #endif -#if JUCE_CLANG - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Wconversion" - #pragma clang diagnostic ignored "-Wshadow" -#endif + #if JUCE_CLANG + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wconversion" + #pragma clang diagnostic ignored "-Wshadow" + #endif #include "oggvorbis/vorbisenc.h" #include "oggvorbis/codec.h" @@ -149,7 +149,7 @@ public: if (destSamples[i] != nullptr) memcpy (destSamples[i] + startOffsetInDestBuffer, reservoir.getSampleData (i, (int) (startSampleInFile - reservoirStart)), - sizeof (float) * numToUse); + sizeof (float) * (size_t) numToUse); startSampleInFile += numToUse; numSamples -= numToUse; @@ -188,7 +188,7 @@ public: { memcpy (reservoir.getSampleData (i, offset), dataIn[i], - sizeof (float) * samps); + sizeof (float) * (size_t) samps); } numToRead -= samps; @@ -204,7 +204,7 @@ public: { for (int i = numDestChannels; --i >= 0;) if (destSamples[i] != nullptr) - zeromem (destSamples[i] + startOffsetInDestBuffer, sizeof (int) * numSamples); + zeromem (destSamples[i] + startOffsetInDestBuffer, sizeof (int) * (size_t) numSamples); } return true; @@ -213,7 +213,7 @@ public: //============================================================================== static size_t oggReadCallback (void* ptr, size_t size, size_t nmemb, void* datasource) { - return (size_t) (static_cast (datasource)->read (ptr, (int) (size * nmemb)) / size); + return (size_t) (static_cast (datasource)->read (ptr, (int) (size * nmemb))) / size; } static int oggSeekCallback (void* datasource, OggVorbisNamespace::ogg_int64_t offset, int whence) diff --git a/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp b/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp index ab4c07d607..e25c580a59 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp +++ b/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp @@ -199,7 +199,7 @@ void AudioFormatReader::readMaxLevels (int64 startSampleInFile, int64 numSamples } const int bufferSize = (int) jmin (numSamples, (int64) 4096); - AudioSampleBuffer tempSampleBuffer (numChannels, bufferSize); + AudioSampleBuffer tempSampleBuffer ((int) numChannels, bufferSize); float** const floatBuffer = tempSampleBuffer.getArrayOfChannels(); int* const* intBuffer = reinterpret_cast (floatBuffer); @@ -219,7 +219,7 @@ void AudioFormatReader::readMaxLevels (int64 startSampleInFile, int64 numSamples numSamples -= numToDo; startSampleInFile += numToDo; - getStereoMinAndMax (floatBuffer, numChannels, numToDo, lmin, lmax, rmin, rmax); + getStereoMinAndMax (floatBuffer, (int) numChannels, numToDo, lmin, lmax, rmin, rmax); } lowestLeft = lmin; @@ -242,7 +242,7 @@ void AudioFormatReader::readMaxLevels (int64 startSampleInFile, int64 numSamples numSamples -= numToDo; startSampleInFile += numToDo; - getStereoMinAndMax (intBuffer, numChannels, numToDo, lmin, lmax, rmin, rmax); + getStereoMinAndMax (intBuffer, (int) numChannels, numToDo, lmin, lmax, rmin, rmax); } lowestLeft = lmin / (float) std::numeric_limits::max(); diff --git a/modules/juce_core/containers/juce_OwnedArray.h b/modules/juce_core/containers/juce_OwnedArray.h index 6423215c99..9e871147cf 100644 --- a/modules/juce_core/containers/juce_OwnedArray.h +++ b/modules/juce_core/containers/juce_OwnedArray.h @@ -317,7 +317,7 @@ public: if (isPositiveAndBelow (indexToInsertAt, numUsed)) { insertPos += indexToInsertAt; - const int numberToMove = numUsed - indexToInsertAt; + const size_t numberToMove = (size_t) (numUsed - indexToInsertAt); memmove (insertPos + numberOfElements, insertPos, numberToMove * sizeof (ObjectClass*)); } else diff --git a/modules/juce_core/memory/juce_Memory.h b/modules/juce_core/memory/juce_Memory.h index 4fb804f78c..46a71006e2 100644 --- a/modules/juce_core/memory/juce_Memory.h +++ b/modules/juce_core/memory/juce_Memory.h @@ -46,8 +46,8 @@ inline void deleteAndZero (Type& pointer) { delete poi This can be useful to avoid casting pointers to a char* and back when you want to move them by a specific number of bytes, */ -template -inline Type* addBytesToPointer (Type* pointer, int bytes) noexcept { return (Type*) (((char*) pointer) + bytes); } +template +inline Type* addBytesToPointer (Type* pointer, IntegerType bytes) noexcept { return (Type*) (((char*) pointer) + bytes); } /** A handy function which returns the difference between any two pointers, in bytes. The address of the second pointer is subtracted from the first, and the difference in bytes is returned. diff --git a/modules/juce_core/native/juce_mac_Files.mm b/modules/juce_core/native/juce_mac_Files.mm index b824ce902e..dd2b3e855a 100644 --- a/modules/juce_core/native/juce_mac_Files.mm +++ b/modules/juce_core/native/juce_mac_Files.mm @@ -233,7 +233,7 @@ File File::getSpecialLocation (const SpecialLocationType type) buffer.calloc (size + 8); _NSGetExecutablePath (buffer.getData(), &size); - return String::fromUTF8 (buffer, size); + return String::fromUTF8 (buffer, (int) size); } default: diff --git a/modules/juce_core/native/juce_mac_Network.mm b/modules/juce_core/native/juce_mac_Network.mm index 42e9fce51a..757bf39985 100644 --- a/modules/juce_core/native/juce_mac_Network.mm +++ b/modules/juce_core/native/juce_mac_Network.mm @@ -160,8 +160,8 @@ public: if (available > 0) { const ScopedLock sl (dataLock); - [data getBytes: dest length: available]; - [data replaceBytesInRange: NSMakeRange (0, available) withBytes: nil length: 0]; + [data getBytes: dest length: (NSUInteger) available]; + [data replaceBytesInRange: NSMakeRange (0, (NSUInteger) available) withBytes: nil length: 0]; numDone += available; numBytes -= available; diff --git a/modules/juce_core/native/juce_mac_Strings.mm b/modules/juce_core/native/juce_mac_Strings.mm index bd025065f2..61b849bf8e 100644 --- a/modules/juce_core/native/juce_mac_Strings.mm +++ b/modules/juce_core/native/juce_mac_Strings.mm @@ -29,7 +29,7 @@ String String::fromCFString (CFStringRef cfString) return String::empty; CFRange range = { 0, CFStringGetLength (cfString) }; - HeapBlock u (range.length + 1); + HeapBlock u ((size_t) range.length + 1); CFStringGetCharacters (cfString, range, u); u[range.length] = 0; @@ -39,7 +39,7 @@ String String::fromCFString (CFStringRef cfString) CFStringRef String::toCFString() const { CharPointer_UTF16 utf16 (toUTF16()); - return CFStringCreateWithCharacters (kCFAllocatorDefault, (const UniChar*) utf16.getAddress(), utf16.length()); + return CFStringCreateWithCharacters (kCFAllocatorDefault, (const UniChar*) utf16.getAddress(), (CFIndex) utf16.length()); } String String::convertToPrecomposedUnicode() const @@ -65,7 +65,7 @@ String String::convertToPrecomposedUnicode() const if (CreateUnicodeToTextInfo (&map, &conversionInfo) == noErr) { - const int bytesNeeded = CharPointer_UTF16::getBytesRequiredFor (getCharPointer()); + const size_t bytesNeeded = CharPointer_UTF16::getBytesRequiredFor (getCharPointer()); HeapBlock tempOut; tempOut.calloc (bytesNeeded + 4); diff --git a/modules/juce_core/native/juce_mac_SystemStats.mm b/modules/juce_core/native/juce_mac_SystemStats.mm index fea2d4b2f5..11ec9ebcef 100644 --- a/modules/juce_core/native/juce_mac_SystemStats.mm +++ b/modules/juce_core/native/juce_mac_SystemStats.mm @@ -68,10 +68,10 @@ SystemStats::CPUFlags::CPUFlags() uint32 familyModel = 0, extFeatures = 0, features = 0, dummy = 0; SystemStatsHelpers::doCPUID (familyModel, extFeatures, dummy, features, 1); - hasMMX = (features & (1 << 23)) != 0; - hasSSE = (features & (1 << 25)) != 0; - hasSSE2 = (features & (1 << 26)) != 0; - has3DNow = (extFeatures & (1 << 31)) != 0; + hasMMX = (features & (1u << 23)) != 0; + hasSSE = (features & (1u << 25)) != 0; + hasSSE2 = (features & (1u << 26)) != 0; + has3DNow = (extFeatures & (1u << 31)) != 0; #else hasMMX = false; hasSSE = false; @@ -235,10 +235,10 @@ public: else { numerator = timebase.numer; - denominator = timebase.denom * (int64) 1000000; + denominator = timebase.denom * (uint64) 1000000; } - highResTimerFrequency = (timebase.denom * (int64) 1000000000) / timebase.numer; + highResTimerFrequency = (timebase.denom * (uint64) 1000000000) / timebase.numer; highResTimerToMillisecRatio = numerator / (double) denominator; } @@ -255,7 +255,7 @@ public: int64 highResTimerFrequency; private: - int64 numerator, denominator; + uint64 numerator, denominator; double highResTimerToMillisecRatio; }; diff --git a/modules/juce_core/native/juce_posix_NamedPipe.cpp b/modules/juce_core/native/juce_posix_NamedPipe.cpp index 130dfc4b69..a61c1a8ccf 100644 --- a/modules/juce_core/native/juce_posix_NamedPipe.cpp +++ b/modules/juce_core/native/juce_posix_NamedPipe.cpp @@ -97,7 +97,7 @@ public: while (bytesRead < maxBytesToRead) { const int bytesThisTime = maxBytesToRead - bytesRead; - const int numRead = (int) ::read (pipeIn, destBuffer, bytesThisTime); + const int numRead = (int) ::read (pipeIn, destBuffer, (size_t) bytesThisTime); if (numRead <= 0) { @@ -140,7 +140,7 @@ public: while (bytesWritten < numBytesToWrite && ! hasExpired (timeoutEnd)) { const int bytesThisTime = numBytesToWrite - bytesWritten; - const int numWritten = (int) ::write (pipeOut, sourceBuffer, bytesThisTime); + const int numWritten = (int) ::write (pipeOut, sourceBuffer, (size_t) bytesThisTime); if (numWritten <= 0) { @@ -172,7 +172,7 @@ private: static uint32 getTimeoutEnd (const int timeOutMilliseconds) { - return timeOutMilliseconds >= 0 ? Time::getMillisecondCounter() + timeOutMilliseconds : 0; + return timeOutMilliseconds >= 0 ? Time::getMillisecondCounter() + (uint32) timeOutMilliseconds : 0; } static bool hasExpired (const uint32 timeoutEnd) diff --git a/modules/juce_core/native/juce_posix_SharedCode.h b/modules/juce_core/native/juce_posix_SharedCode.h index a34bb12101..80c2faf301 100644 --- a/modules/juce_core/native/juce_posix_SharedCode.h +++ b/modules/juce_core/native/juce_posix_SharedCode.h @@ -205,7 +205,7 @@ File File::getCurrentWorkingDirectory() char localBuffer [1024]; char* cwd = getcwd (localBuffer, sizeof (localBuffer) - 1); - int bufferSize = 4096; + size_t bufferSize = 4096; while (cwd == nullptr && errno == ERANGE) { @@ -500,7 +500,7 @@ int FileOutputStream::writeInternal (const void* const data, const int numBytes) if (fileHandle != 0) { - result = ::write (getFD (fileHandle), data, numBytes); + result = ::write (getFD (fileHandle), data, (size_t) numBytes); if (result == -1) status = getResultForErrno(); @@ -1046,7 +1046,7 @@ public: readHandle = fdopen (pipeHandle, "r"); if (readHandle != 0) - return fread (dest, 1, numBytes, readHandle); + return (int) fread (dest, 1, (size_t) numBytes, readHandle); return 0; } diff --git a/modules/juce_core/network/juce_Socket.cpp b/modules/juce_core/network/juce_Socket.cpp index b6fea1f113..fa830cb109 100644 --- a/modules/juce_core/network/juce_Socket.cpp +++ b/modules/juce_core/network/juce_Socket.cpp @@ -97,7 +97,7 @@ namespace SocketHelpers #if JUCE_WINDOWS bytesThisTime = recv (handle, static_cast (destBuffer) + bytesRead, maxBytesToRead - bytesRead, 0); #else - while ((bytesThisTime = (int) ::read (handle, addBytesToPointer (destBuffer, bytesRead), maxBytesToRead - bytesRead)) < 0 + while ((bytesThisTime = (int) ::read (handle, addBytesToPointer (destBuffer, bytesRead), (size_t) (maxBytesToRead - bytesRead))) < 0 && errno == EINTR && connected) { @@ -230,7 +230,7 @@ namespace SocketHelpers } setSocketBlockingState (handle, false); - const int result = ::connect (handle, info->ai_addr, (int) info->ai_addrlen); + const int result = ::connect (handle, info->ai_addr, (socklen_t) info->ai_addrlen); freeaddrinfo (info); if (result < 0) @@ -301,7 +301,7 @@ int StreamingSocket::write (const void* sourceBuffer, const int numBytesToWrite) #else int result; - while ((result = (int) ::write (handle, sourceBuffer, numBytesToWrite)) < 0 + while ((result = (int) ::write (handle, sourceBuffer, (size_t) numBytesToWrite)) < 0 && errno == EINTR) { } @@ -564,7 +564,7 @@ int DatagramSocket::write (const void* sourceBuffer, const int numBytesToWrite) jassert (serverAddress != nullptr && connected); return connected ? (int) sendto (handle, (const char*) sourceBuffer, - numBytesToWrite, 0, + (size_t) numBytesToWrite, 0, static_cast (serverAddress)->ai_addr, static_cast (serverAddress)->ai_addrlen) : -1; diff --git a/modules/juce_core/streams/juce_MemoryInputStream.cpp b/modules/juce_core/streams/juce_MemoryInputStream.cpp index b1cfce9f22..0269737670 100644 --- a/modules/juce_core/streams/juce_MemoryInputStream.cpp +++ b/modules/juce_core/streams/juce_MemoryInputStream.cpp @@ -69,7 +69,7 @@ int MemoryInputStream::read (void* const buffer, const int howMany) return 0; memcpy (buffer, addBytesToPointer (data, position), (size_t) num); - position += num; + position += (unsigned int) num; return num; } diff --git a/modules/juce_core/streams/juce_MemoryOutputStream.cpp b/modules/juce_core/streams/juce_MemoryOutputStream.cpp index 40492634c2..713ba64aec 100644 --- a/modules/juce_core/streams/juce_MemoryOutputStream.cpp +++ b/modules/juce_core/streams/juce_MemoryOutputStream.cpp @@ -70,10 +70,11 @@ void MemoryOutputStream::reset() noexcept void MemoryOutputStream::prepareToWrite (int numBytes) { - const size_t storageNeeded = position + numBytes; + jassert (numBytes >= 0); + size_t storageNeeded = position + (size_t) numBytes; if (storageNeeded >= data.getSize()) - data.ensureSize ((storageNeeded + jmin ((int) (storageNeeded / 2), 1024 * 1024) + 32) & ~31); + data.ensureSize ((storageNeeded + jmin (storageNeeded / 2, (size_t) (1024 * 1024)) + 32) & ~31u); } bool MemoryOutputStream::write (const void* const buffer, int howMany) @@ -84,7 +85,7 @@ bool MemoryOutputStream::write (const void* const buffer, int howMany) { prepareToWrite (howMany); memcpy (static_cast (data.getData()) + position, buffer, (size_t) howMany); - position += howMany; + position += (size_t) howMany; size = jmax (size, position); } @@ -97,7 +98,7 @@ void MemoryOutputStream::writeRepeatedByte (uint8 byte, int howMany) { prepareToWrite (howMany); memset (static_cast (data.getData()) + position, byte, (size_t) howMany); - position += howMany; + position += (size_t) howMany; size = jmax (size, position); } } diff --git a/modules/juce_core/text/juce_CharacterFunctions.cpp b/modules/juce_core/text/juce_CharacterFunctions.cpp index e58814f7b9..e74154c3e3 100644 --- a/modules/juce_core/text/juce_CharacterFunctions.cpp +++ b/modules/juce_core/text/juce_CharacterFunctions.cpp @@ -107,7 +107,7 @@ bool CharacterFunctions::isLetterOrDigit (const juce_wchar character) noexcept int CharacterFunctions::getHexDigitValue (const juce_wchar digit) noexcept { - unsigned int d = digit - '0'; + unsigned int d = (unsigned int) digit - '0'; if (d < (unsigned int) 10) return (int) d; diff --git a/modules/juce_core/text/juce_CharacterFunctions.h b/modules/juce_core/text/juce_CharacterFunctions.h index 35299971dc..74d574a2fb 100644 --- a/modules/juce_core/text/juce_CharacterFunctions.h +++ b/modules/juce_core/text/juce_CharacterFunctions.h @@ -343,7 +343,7 @@ public: dest.writeNull(); - return (int) (getAddressDifference (dest.getAddress(), startAddress) + sizeof (typename DestCharPointerType::CharType)); + return (int) ((size_t) getAddressDifference (dest.getAddress(), startAddress) + sizeof (typename DestCharPointerType::CharType)); } /** Copies characters from one string to another, up to a null terminator diff --git a/modules/juce_core/text/juce_String.cpp b/modules/juce_core/text/juce_String.cpp index 0701ab8d09..3f5470ae1e 100644 --- a/modules/juce_core/text/juce_String.cpp +++ b/modules/juce_core/text/juce_String.cpp @@ -133,7 +133,7 @@ public: if (start.getAddress() == nullptr || start.isEmpty()) return getEmpty(); - const size_t numBytes = end.getAddress() - start.getAddress(); + const size_t numBytes = (size_t) (end.getAddress() - start.getAddress()); const CharPointerType dest (createUninitialisedBytes (numBytes + 1)); memcpy (dest.getAddress(), start, numBytes); dest.getAddress()[numBytes] = 0; @@ -683,7 +683,7 @@ String& String::operator+= (const int number) { const size_t byteOffsetOfNull = getByteOffsetOfEnd(); const size_t newBytesNeeded = sizeof (CharPointerType::CharType) + byteOffsetOfNull - + sizeof (CharPointerType::CharType) * numExtraChars; + + sizeof (CharPointerType::CharType) * (size_t) numExtraChars; text = StringHolder::makeUniqueWithByteSize (text, newBytesNeeded); @@ -1051,7 +1051,7 @@ String String::repeatedString (const String& stringToRepeat, int numberOfTimesTo if (numberOfTimesToRepeat <= 0) return empty; - String result (PreallocationBytes (stringToRepeat.getByteOffsetOfEnd() * numberOfTimesToRepeat)); + String result (PreallocationBytes (stringToRepeat.getByteOffsetOfEnd() * (size_t) numberOfTimesToRepeat)); CharPointerType n (result.text); while (--numberOfTimesToRepeat >= 0) @@ -1077,7 +1077,7 @@ String String::paddedLeft (const juce_wchar padCharacter, int minimumLength) con return *this; const size_t currentByteSize = (size_t) (((char*) end.getAddress()) - (char*) text.getAddress()); - String result (PreallocationBytes (currentByteSize + extraChars * CharPointerType::getBytesRequiredFor (padCharacter))); + String result (PreallocationBytes (currentByteSize + (size_t) extraChars * CharPointerType::getBytesRequiredFor (padCharacter))); CharPointerType n (result.text); while (--extraChars >= 0) @@ -1104,7 +1104,7 @@ String String::paddedRight (const juce_wchar padCharacter, int minimumLength) co return *this; const size_t currentByteSize = (size_t) (((char*) end.getAddress()) - (char*) text.getAddress()); - String result (PreallocationBytes (currentByteSize + extraChars * CharPointerType::getBytesRequiredFor (padCharacter))); + String result (PreallocationBytes (currentByteSize + (size_t) extraChars * CharPointerType::getBytesRequiredFor (padCharacter))); CharPointerType n (result.text); n.writeAll (text); @@ -1985,7 +1985,7 @@ struct StringEncodingConverter CharPointerType_Src text (source.getCharPointer()); const size_t extraBytesNeeded = CharPointerType_Dest::getBytesRequiredFor (text); - const size_t endOffset = (text.sizeInBytes() + 3) & ~3; // the new string must be word-aligned or many Windows + const size_t endOffset = (text.sizeInBytes() + 3) & ~3u; // the new string must be word-aligned or many Windows // functions will fail to read it correctly! source.preallocateBytes (endOffset + extraBytesNeeded); text = source.getCharPointer(); @@ -1994,8 +1994,8 @@ struct StringEncodingConverter const CharPointerType_Dest extraSpace (static_cast (newSpace)); #if JUCE_DEBUG // (This just avoids spurious warnings from valgrind about the uninitialised bytes at the end of the buffer..) - const int bytesToClear = jmin ((int) extraBytesNeeded, 4); - zeromem (addBytesToPointer (newSpace, (int) (extraBytesNeeded - bytesToClear)), (size_t) bytesToClear); + const size_t bytesToClear = (size_t) jmin ((int) extraBytesNeeded, 4); + zeromem (addBytesToPointer (newSpace, extraBytesNeeded - bytesToClear), bytesToClear); #endif CharPointerType_Dest (extraSpace).writeAll (text); @@ -2113,7 +2113,7 @@ public: CharPointerType (buffer).writeAll (s.toUTF8()); test.expectEquals (String (CharPointerType (buffer)), s); - test.expect (CharPointerType::isValidString (buffer, strlen ((const char*) buffer))); + test.expect (CharPointerType::isValidString (buffer, (int) strlen ((const char*) buffer))); } }; diff --git a/modules/juce_core/text/juce_StringArray.cpp b/modules/juce_core/text/juce_StringArray.cpp index 47de97dbd8..351c0a21ff 100644 --- a/modules/juce_core/text/juce_StringArray.cpp +++ b/modules/juce_core/text/juce_StringArray.cpp @@ -328,7 +328,7 @@ String StringArray::joinIntoString (const String& separator, int start, int numb return strings.getReference (start); const size_t separatorBytes = separator.getCharPointer().sizeInBytes() - sizeof (String::CharPointerType::CharType); - size_t bytesNeeded = separatorBytes * (last - start - 1); + size_t bytesNeeded = separatorBytes * (size_t) (last - start - 1); for (int i = start; i < last; ++i) bytesNeeded += strings.getReference(i).getCharPointer().sizeInBytes() - sizeof (String::CharPointerType::CharType); diff --git a/modules/juce_core/text/juce_TextDiff.cpp b/modules/juce_core/text/juce_TextDiff.cpp index 9d4ba01fae..a303436ec7 100644 --- a/modules/juce_core/text/juce_TextDiff.cpp +++ b/modules/juce_core/text/juce_TextDiff.cpp @@ -42,7 +42,7 @@ struct TextDiffHelpers static void addInsertion (TextDiff& td, const String::CharPointerType& text, int index, int length) { TextDiff::Change c; - c.insertedText = String (text, length); + c.insertedText = String (text, (size_t) length); c.start = index; c.length = length; td.changes.add (c); @@ -84,7 +84,7 @@ struct TextDiffHelpers { jassert (indexA >= 0 && indexA <= a.length); jassert (indexB >= 0 && indexB <= b.length); - jassert (String (a.text + indexA, len) == String (b.text + indexB, len)); + jassert (String (a.text + indexA, (size_t) len) == String (b.text + indexB, (size_t) len)); if (indexA > 0 && indexB > 0) diffSkippingCommonStart (td, StringRegion (a.text, a.start, indexA), @@ -112,7 +112,7 @@ struct TextDiffHelpers return 0; HeapBlock lines; - lines.calloc (lenB * 2 + 2); + lines.calloc (2 + 2 * (size_t) lenB); int* l0 = lines; int* l1 = l0 + lenB + 1; diff --git a/modules/juce_core/threads/juce_ChildProcess.cpp b/modules/juce_core/threads/juce_ChildProcess.cpp index 723e8788f2..da5e85edd6 100644 --- a/modules/juce_core/threads/juce_ChildProcess.cpp +++ b/modules/juce_core/threads/juce_ChildProcess.cpp @@ -28,7 +28,7 @@ ChildProcess::~ChildProcess() {} bool ChildProcess::waitForProcessToFinish (const int timeoutMs) const { - const int64 timeoutTime = Time::getMillisecondCounter() + timeoutMs; + const uint32 timeoutTime = Time::getMillisecondCounter() + (uint32) timeoutMs; do { diff --git a/modules/juce_core/threads/juce_Thread.cpp b/modules/juce_core/threads/juce_Thread.cpp index 2cf56f85b8..9ea9aecdcc 100644 --- a/modules/juce_core/threads/juce_Thread.cpp +++ b/modules/juce_core/threads/juce_Thread.cpp @@ -156,7 +156,7 @@ bool Thread::waitForThreadToExit (const int timeOutMilliseconds) const // Doh! So how exactly do you expect this thread to wait for itself to stop?? jassert (getThreadId() != getCurrentThreadId() || getCurrentThreadId() == 0); - const uint32 timeoutEnd = Time::getMillisecondCounter() + timeOutMilliseconds; + const uint32 timeoutEnd = Time::getMillisecondCounter() + (uint32) timeOutMilliseconds; while (isThreadRunning()) { diff --git a/modules/juce_core/threads/juce_ThreadPool.cpp b/modules/juce_core/threads/juce_ThreadPool.cpp index f73c8846c9..ae487341fc 100644 --- a/modules/juce_core/threads/juce_ThreadPool.cpp +++ b/modules/juce_core/threads/juce_ThreadPool.cpp @@ -170,7 +170,7 @@ bool ThreadPool::waitForJobToFinish (const ThreadPoolJob* const job, while (contains (job)) { - if (timeOutMs >= 0 && Time::getMillisecondCounter() >= start + timeOutMs) + if (timeOutMs >= 0 && Time::getMillisecondCounter() >= start + (uint32) timeOutMs) return false; jobFinishedSignal.wait (2); @@ -260,7 +260,7 @@ bool ThreadPool::removeAllJobs (const bool interruptRunningJobs, const int timeO if (jobsToWaitFor.size() == 0) break; - if (timeOutMs >= 0 && Time::getMillisecondCounter() >= start + timeOutMs) + if (timeOutMs >= 0 && Time::getMillisecondCounter() >= start + (uint32) timeOutMs) return false; jobFinishedSignal.wait (20); diff --git a/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp b/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp index af25e047d6..bca8a0b2e7 100644 --- a/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp +++ b/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp @@ -46,7 +46,7 @@ public: zlibNamespace::deflateEnd (&stream); } - bool write (const uint8* data, int dataSize, OutputStream& out) + bool write (const uint8* data, unsigned int dataSize, OutputStream& out) { // When you call flush() on a gzip stream, the stream is closed, and you can // no longer continue to write data to it! @@ -62,7 +62,7 @@ public: void finish (OutputStream& out) { const uint8* data = nullptr; - int dataSize = 0; + unsigned int dataSize = 0; while (! finished) doNextBlock (data, dataSize, out, Z_FINISH); @@ -76,7 +76,7 @@ private: bool isFirstDeflate, streamIsValid, finished; zlibNamespace::Bytef buffer[32768]; - bool doNextBlock (const uint8*& data, int& dataSize, OutputStream& out, const int flushMode) + bool doNextBlock (const uint8*& data, unsigned int& dataSize, OutputStream& out, const int flushMode) { using namespace zlibNamespace; if (streamIsValid) @@ -98,7 +98,7 @@ private: case Z_OK: { data += dataSize - stream.avail_in; - dataSize = (int) stream.avail_in; + dataSize = stream.avail_in; const int bytesDone = ((int) sizeof (buffer)) - (int) stream.avail_out; return bytesDone <= 0 || out.write (buffer, bytesDone); } @@ -140,7 +140,8 @@ bool GZIPCompressorOutputStream::write (const void* destBuffer, int howMany) { jassert (destBuffer != nullptr && howMany >= 0); - return helper->write (static_cast (destBuffer), howMany, *destStream); + return helper->write (static_cast (destBuffer), + (unsigned int) howMany, *destStream); } int64 GZIPCompressorOutputStream::getPosition() @@ -176,7 +177,7 @@ public: for (int j = rng.nextInt (100); --j >= 0;) { - MemoryBlock data (rng.nextInt (2000) + 1); + MemoryBlock data ((unsigned int) (rng.nextInt (2000) + 1)); for (int k = (int) data.getSize(); --k >= 0;) data[k] = (char) rng.nextInt (255); diff --git a/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp b/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp index 65d23df203..3f8ed5b8fa 100644 --- a/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp +++ b/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp @@ -109,7 +109,7 @@ public: dataSize = size; } - int doNextBlock (uint8* const dest, const int destSize) + int doNextBlock (uint8* const dest, const unsigned int destSize) { using namespace zlibNamespace; if (streamIsValid && data != nullptr && ! finished) @@ -209,7 +209,7 @@ int GZIPDecompressorInputStream::read (void* destBuffer, int howMany) while (! helper->error) { - const int n = helper->doNextBlock (d, howMany); + const int n = helper->doNextBlock (d, (unsigned int) howMany); currentPos += n; if (n == 0) diff --git a/modules/juce_graphics/fonts/juce_Font.cpp b/modules/juce_graphics/fonts/juce_Font.cpp index acf6f09704..7ff251c5b4 100644 --- a/modules/juce_graphics/fonts/juce_Font.cpp +++ b/modules/juce_graphics/fonts/juce_Font.cpp @@ -89,7 +89,7 @@ public: } int replaceIndex = 0; - size_t bestLastUsageCount = std::numeric_limits::max(); + size_t bestLastUsageCount = std::numeric_limits::max(); for (int i = faces.size(); --i >= 0;) { diff --git a/modules/juce_graphics/image_formats/juce_JPEGLoader.cpp b/modules/juce_graphics/image_formats/juce_JPEGLoader.cpp index 5cee5fe455..70b1979826 100644 --- a/modules/juce_graphics/image_formats/juce_JPEGLoader.cpp +++ b/modules/juce_graphics/image_formats/juce_JPEGLoader.cpp @@ -391,7 +391,7 @@ bool JPEGImageFormat::writeImageToStream (const Image& image, OutputStream& out) jpeg_start_compress (&jpegCompStruct, TRUE); - const int strideBytes = (int) (jpegCompStruct.image_width * jpegCompStruct.input_components); + const int strideBytes = (int) (jpegCompStruct.image_width * (unsigned int) jpegCompStruct.input_components); JSAMPARRAY buffer = (*jpegCompStruct.mem->alloc_sarray) ((j_common_ptr) &jpegCompStruct, JPOOL_IMAGE, (JDIMENSION) strideBytes, 1); diff --git a/modules/juce_graphics/image_formats/juce_PNGLoader.cpp b/modules/juce_graphics/image_formats/juce_PNGLoader.cpp index 6905ff4ed5..f569594ebc 100644 --- a/modules/juce_graphics/image_formats/juce_PNGLoader.cpp +++ b/modules/juce_graphics/image_formats/juce_PNGLoader.cpp @@ -55,6 +55,11 @@ namespace pnglibNamespace using std::free; #endif + #if JUCE_CLANG + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wsign-conversion" + #endif + using std::abs; #define PNG_INTERNAL #define NO_DUMMY_DECL @@ -79,6 +84,10 @@ namespace pnglibNamespace #include "pnglib/pngwrite.c" #include "pnglib/pngwtran.c" #include "pnglib/pngwutil.c" + + #if JUCE_CLANG + #pragma clang diagnostic pop + #endif #else extern "C" { diff --git a/modules/juce_graphics/images/juce_Image.cpp b/modules/juce_graphics/images/juce_Image.cpp index d3a31f7978..d0846f8789 100644 --- a/modules/juce_graphics/images/juce_Image.cpp +++ b/modules/juce_graphics/images/juce_Image.cpp @@ -51,7 +51,7 @@ Image ImageType::convert (const Image& source) const jassert (src.pixelStride == dest.pixelStride && src.pixelFormat == dest.pixelFormat); for (int y = 0; y < dest.height; ++y) - memcpy (dest.getLinePointer (y), src.getLinePointer (y), dest.lineStride); + memcpy (dest.getLinePointer (y), src.getLinePointer (y), (size_t) dest.lineStride); return newImage; } diff --git a/modules/juce_graphics/images/juce_ImageCache.cpp b/modules/juce_graphics/images/juce_ImageCache.cpp index cac8d6a028..ba7088675d 100644 --- a/modules/juce_graphics/images/juce_ImageCache.cpp +++ b/modules/juce_graphics/images/juce_ImageCache.cpp @@ -101,7 +101,7 @@ public: uint32 lastUseTime; }; - int cacheTimeout; + unsigned int cacheTimeout; juce_DeclareSingleton_SingleThreaded_Minimal (ImageCache::Pimpl); @@ -159,5 +159,6 @@ Image ImageCache::getFromMemory (const void* imageData, const int dataSize) void ImageCache::setCacheTimeout (const int millisecs) { - Pimpl::getInstance()->cacheTimeout = millisecs; + jassert (millisecs >= 0); + Pimpl::getInstance()->cacheTimeout = (unsigned int) millisecs; } diff --git a/modules/juce_graphics/native/juce_mac_Fonts.mm b/modules/juce_graphics/native/juce_mac_Fonts.mm index a74ab83347..cc2f7a4a63 100644 --- a/modules/juce_graphics/native/juce_mac_Fonts.mm +++ b/modules/juce_graphics/native/juce_mac_Fonts.mm @@ -130,7 +130,7 @@ namespace CoreTextTypeLayout { if (advances == nullptr) { - local.malloc (numGlyphs); + local.malloc ((size_t) numGlyphs); CTRunGetAdvances (run, CFRangeMake (0, 0), local); advances = local; } @@ -142,7 +142,7 @@ namespace CoreTextTypeLayout struct Glyphs { - Glyphs (CTRunRef run, const int numGlyphs) + Glyphs (CTRunRef run, const size_t numGlyphs) : glyphs (CTRunGetGlyphsPtr (run)) { if (glyphs == nullptr) @@ -159,7 +159,7 @@ namespace CoreTextTypeLayout struct Positions { - Positions (CTRunRef run, const int numGlyphs) + Positions (CTRunRef run, const size_t numGlyphs) : points (CTRunGetPositionsPtr (run)) { if (points == nullptr) @@ -383,9 +383,9 @@ namespace CoreTextTypeLayout glyphRun->colour = Colour::fromFloatRGBA (components[0], components[1], components[2], components[3]); } - const CoreTextTypeLayout::Glyphs glyphs (run, numGlyphs); + const CoreTextTypeLayout::Glyphs glyphs (run, (size_t) numGlyphs); const CoreTextTypeLayout::Advances advances (run, numGlyphs); - const CoreTextTypeLayout::Positions positions (run, numGlyphs); + const CoreTextTypeLayout::Positions positions (run, (size_t) numGlyphs); for (CFIndex k = 0; k < numGlyphs; ++k) glyphRun->glyphs.add (TextLayout::Glyph (glyphs.glyphs[k], Point (positions.points[k].x, @@ -511,7 +511,7 @@ public: CFIndex length = CTRunGetGlyphCount (run); const CoreTextTypeLayout::Advances advances (run, length); - const CoreTextTypeLayout::Glyphs glyphs (run, length); + const CoreTextTypeLayout::Glyphs glyphs (run, (size_t) length); for (int j = 0; j < length; ++j) { diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp index a94b7f04ad..95f20abc27 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp @@ -211,7 +211,7 @@ LookAndFeel::LookAndFeel() }; for (int i = 0; i < numElementsInArray (standardColours); i += 2) - setColour (standardColours [i], Colour ((uint32) standardColours [i + 1])); + setColour ((int) standardColours [i], Colour ((uint32) standardColours [i + 1])); juce_getTypefaceForFont = LookAndFeelHelpers::getTypefaceForFontFromLookAndFeel; } diff --git a/modules/juce_gui_basics/native/juce_mac_MainMenu.mm b/modules/juce_gui_basics/native/juce_mac_MainMenu.mm index e0f8bc55d0..2fb8824ff5 100644 --- a/modules/juce_gui_basics/native/juce_mac_MainMenu.mm +++ b/modules/juce_gui_basics/native/juce_mac_MainMenu.mm @@ -233,7 +233,7 @@ public: [item setState: iter.isTicked ? NSOnState : NSOffState]; [item setTarget: (id) callback]; - NSMutableArray* info = [NSMutableArray arrayWithObject: [NSNumber numberWithUnsignedLongLong: (pointer_sized_int) (void*) iter.commandManager]]; + NSMutableArray* info = [NSMutableArray arrayWithObject: [NSNumber numberWithUnsignedLongLong: (pointer_sized_uint) (void*) iter.commandManager]]; [info addObject: [NSNumber numberWithInt: topLevelIndex]]; [item setRepresentedObject: info]; diff --git a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index 7e647177c0..29531c51dc 100644 --- a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -1506,7 +1506,7 @@ private: static NSRange markedRange (id self, SEL) { NSViewComponentPeer* const owner = getOwner (self); - return owner->stringBeingComposed.isNotEmpty() ? NSMakeRange (0, owner->stringBeingComposed.length()) + return owner->stringBeingComposed.isNotEmpty() ? NSMakeRange (0, (NSUInteger) owner->stringBeingComposed.length()) : NSMakeRange (NSNotFound, 0); } @@ -1519,7 +1519,8 @@ private: const Range highlight (target->getHighlightedRegion()); if (! highlight.isEmpty()) - return NSMakeRange (highlight.getStart(), highlight.getLength()); + return NSMakeRange ((NSUInteger) highlight.getStart(), + (NSUInteger) highlight.getLength()); } } diff --git a/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp b/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp index c95daef01a..1608ddb3aa 100644 --- a/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp @@ -183,7 +183,7 @@ void TooltipWindow::timerCallback() // appear after a timeout.. if (newTip.isNotEmpty() && newTip != tipShowing - && now > lastCompChangeTime + millisecondsBeforeTipAppears) + && now > lastCompChangeTime + (unsigned int) millisecondsBeforeTipAppears) { showFor (newTip); } diff --git a/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.cpp b/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.cpp index 26c32d3203..8d2de3c665 100644 --- a/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.cpp +++ b/modules/juce_gui_extra/code_editor/juce_CPlusPlusCodeTokeniser.cpp @@ -60,7 +60,7 @@ CodeEditorComponent::ColourScheme CPlusPlusCodeTokeniser::getDefaultColourScheme CodeEditorComponent::ColourScheme cs; - for (int i = 0; i < sizeof (types) / sizeof (types[0]); ++i) // (NB: numElementsInArray doesn't work here in GCC4.2) + for (unsigned int i = 0; i < sizeof (types) / sizeof (types[0]); ++i) // (NB: numElementsInArray doesn't work here in GCC4.2) cs.set (types[i].name, Colour (types[i].colour)); return cs; diff --git a/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.cpp b/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.cpp index 3f3cff3142..5de027eee1 100644 --- a/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.cpp +++ b/modules/juce_gui_extra/misc/juce_BubbleMessageComponent.cpp @@ -69,7 +69,7 @@ void BubbleMessageComponent::init (const int numMillisecondsBeforeRemoving, deleteAfterUse = deleteSelfAfterUse; expiryTime = numMillisecondsBeforeRemoving > 0 - ? (Time::getMillisecondCounter() + numMillisecondsBeforeRemoving) : 0; + ? (Time::getMillisecondCounter() + (uint32) numMillisecondsBeforeRemoving) : 0; mouseClickCounter = Desktop::getInstance().getMouseButtonClickCounter(); diff --git a/modules/juce_opengl/native/juce_OpenGL_osx.h b/modules/juce_opengl/native/juce_OpenGL_osx.h index 020ba0360f..e7fc90e4f1 100644 --- a/modules/juce_opengl/native/juce_OpenGL_osx.h +++ b/modules/juce_opengl/native/juce_OpenGL_osx.h @@ -100,8 +100,8 @@ class OpenGLContext::NativeContext { public: NativeContext (Component& component, - const OpenGLPixelFormat& pixelFormat, - void* contextToShareWith) + const OpenGLPixelFormat& pixFormat, + void* contextToShare) { NSOpenGLPixelFormatAttribute attribs[] = { @@ -109,14 +109,14 @@ public: NSOpenGLPFAMPSafe, NSOpenGLPFAClosestPolicy, NSOpenGLPFANoRecovery, - NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute) (pixelFormat.redBits + pixelFormat.greenBits + pixelFormat.blueBits), - NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute) pixelFormat.alphaBits, - NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute) pixelFormat.depthBufferBits, - NSOpenGLPFAStencilSize, (NSOpenGLPixelFormatAttribute) pixelFormat.stencilBufferBits, - NSOpenGLPFAAccumSize, (NSOpenGLPixelFormatAttribute) (pixelFormat.accumulationBufferRedBits + pixelFormat.accumulationBufferGreenBits - + pixelFormat.accumulationBufferBlueBits + pixelFormat.accumulationBufferAlphaBits), - pixelFormat.multisamplingLevel > 0 ? NSOpenGLPFASamples : (NSOpenGLPixelFormatAttribute) 0, - (NSOpenGLPixelFormatAttribute) pixelFormat.multisamplingLevel, + NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute) (pixFormat.redBits + pixFormat.greenBits + pixFormat.blueBits), + NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute) pixFormat.alphaBits, + NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute) pixFormat.depthBufferBits, + NSOpenGLPFAStencilSize, (NSOpenGLPixelFormatAttribute) pixFormat.stencilBufferBits, + NSOpenGLPFAAccumSize, (NSOpenGLPixelFormatAttribute) (pixFormat.accumulationBufferRedBits + pixFormat.accumulationBufferGreenBits + + pixFormat.accumulationBufferBlueBits + pixFormat.accumulationBufferAlphaBits), + pixFormat.multisamplingLevel > 0 ? NSOpenGLPFASamples : (NSOpenGLPixelFormatAttribute) 0, + (NSOpenGLPixelFormatAttribute) pixFormat.multisamplingLevel, 0 }; @@ -133,7 +133,7 @@ public: object: view]; renderContext = [[[NSOpenGLContext alloc] initWithFormat: format - shareContext: (NSOpenGLContext*) contextToShareWith] autorelease]; + shareContext: (NSOpenGLContext*) contextToShare] autorelease]; setSwapInterval (1); diff --git a/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp b/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp index 3cf0900db9..da09e35ac5 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp @@ -150,7 +150,7 @@ class OpenGLFrameBuffer::SavedState public: SavedState (OpenGLFrameBuffer& buffer, const int w, const int h) : width (w), height (h), - data (w * h) + data ((size_t) (w * h)) { buffer.readPixels (data, Rectangle (w, h)); } diff --git a/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.cpp b/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.cpp index 2bb644bf3a..bfda40747c 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.cpp @@ -62,9 +62,9 @@ bool OpenGLShaderProgram::addShader (const char* const code, GLenum type) if (status == GL_FALSE) { GLchar infoLog [16384]; - GLsizei infologLength = 0; - context.extensions.glGetShaderInfoLog (shaderID, sizeof (infoLog), &infologLength, infoLog); - errorLog = String (infoLog, infologLength); + GLsizei infoLogLength = 0; + context.extensions.glGetShaderInfoLog (shaderID, sizeof (infoLog), &infoLogLength, infoLog); + errorLog = String (infoLog, (size_t) infoLogLength); #if JUCE_DEBUG DBG (errorLog); @@ -90,9 +90,9 @@ bool OpenGLShaderProgram::link() noexcept if (status == GL_FALSE) { GLchar infoLog [16384]; - GLsizei infologLength = 0; - context.extensions.glGetProgramInfoLog (programID, sizeof (infoLog), &infologLength, infoLog); - errorLog = String (infoLog, infologLength); + GLsizei infoLogLength = 0; + context.extensions.glGetProgramInfoLog (programID, sizeof (infoLog), &infoLogLength, infoLog); + errorLog = String (infoLog, (size_t) infoLogLength); #if JUCE_DEBUG DBG (errorLog); diff --git a/modules/juce_opengl/opengl/juce_OpenGLTexture.cpp b/modules/juce_opengl/opengl/juce_OpenGLTexture.cpp index c6a42bbe1d..bd754099ea 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLTexture.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLTexture.cpp @@ -79,7 +79,7 @@ struct Flipper static void flip (HeapBlock& dataCopy, const uint8* srcData, const int lineStride, const int w, const int h, const int textureW, const int textureH) { - dataCopy.malloc (textureW * textureH); + dataCopy.malloc ((size_t) (textureW * textureH)); for (int y = 0; y < h; ++y) {